Jump to content

In Firefox: How to Delete All Cookies, Except a Defined Group Held in an Array?


Zohar
 Share

Recommended Posts

Hi


Browsers tend to accumulate a lot of cookies,
90% of them are from Ad sites.


I would like to create an array with a defined group of sites that I wish their cookies not to be deleted,
and then write a script that deletes all cookies except ones defined in that array.


Doing it via Firefox's GUI seems problematic and fragile..
Is there maybe a programmatic way to do it?


Thank you

Edited by Zohar
Link to comment
Share on other sites

 

That functionality is already built into Firefox.  There's no fragility in its implementation.  It works quite well.

 

image.png.322b6b229f74e76dc9492b53912bfa6d.png

Link to comment
Share on other sites

Hi TheXman


The interface you got looks different than mine.

When I go to the Privacy tab, I only have "Remove Individual Cookies".

I am using Windows XP SP3, and Firefox 52.9.0 (the latest, and probably the last version released for XP)

Link to comment
Share on other sites

The same functionality that I have referenced above existed in FF v52 and long before that, just in a different place in the Options dialogs.  Unfortunately, I don't have an XP VM to show you where it exists.  If I recall, it is on the Privacy section in v52.

Link to comment
Share on other sites

Well you are right :)

There is a field:
"Firefox will:", and then it has a Combobox.
Initially the Combobox's value is "Remember history".

If you click that Combobox and choose "Use custom settings for history",
then the "Exceptions..." button appears  (right after the "Accept cookies from sites" label).


This is nice but it has 1 problems:
After you define your list, Firefox does not provide you any way to export/import it.

So if you want to format your PC, or use Firefox on more than one computer,
you will have to manually replicate it again on each computer.


With a script tho, it will be much easier to reproduce on any needed computer/after formatting.


So I would really like a programmatic way to do it,
If someone knows how..

Edited by Zohar
Link to comment
Share on other sites

Hi
I run the same Firefox version (52.9.0) and I use a small extension named "selective cookie delete" (though a better name would be "selective cookie keep")  :)
The list of the cookies to keep can be seen in about:config on the line 'selectivecookiedelete.cookiestokeep' and can be easily extracted from the Firefox "prefs.js" file, line : user_pref("selectivecookiedelete.cookiestokeep", "www.autoitscript.com, www.autoitscript.fr");

I assume that there are still many extensions like this, long time ago I chose this one among many others

 

 

Link to comment
Share on other sites

Hi mikell


Thank you very much.

Nice to know such thing exists.

But since the work to create such a thing should not be big,
I would like to write a small script myself that does it, instead of installing any additional (outside) add-on.


If anyone can recommend how to do it programatically, it would be interesting to see.

Link to comment
Share on other sites

hi @Zohar,

never gone into this matter, but I suppose that, since firefox cookies are stored into an sqlite file called cookies.sqlite, you culd try to use some sql queryes to manage that archive...

if you type about:support in the firefox address bar, you can see among aother infos, where is located that file (see the profile folder path).

Edited by Chimp

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to comment
Share on other sites

A start point...

#include <SQLite.au3>
#include <Array.au3>

$db = "C:\Documents and Settings\mikell\Application Data\Mozilla\Firefox\Profiles\*****.default\cookies.sqlite"

_SQLite_Startup()
_SQLite_Open($db)
 
Local $array
_SQLite_GetTable2d (-1, "SELECT * FROM moz_cookies;", $array, 0, 0)
  _ArrayDisplay($array)

_SQLite_Close()
_SQLite_Shutdown()

 

Link to comment
Share on other sites

20 hours ago, Chimp said:

hi @Zohar,

never gone into this matter, but I suppose that, since firefox cookies are stored into an sqlite file called cookies.sqlite, you culd try to use some sql queryes to manage that archive...

if you type about:support in the firefox address bar, you can see among aother infos, where is located that file (see the profile folder path).

That's terrific..

I found it thanks to your good pointing to it,
and opened it with "SQLite Expert Personal", which I was recommended about by people here in the past :)

It has a very simple structure..

I will definitely prefer this route,
but I want to ask another thing:

Changing the DB will be very easy (programmatically), but is a bit intrusive towards Firefox.
It might cause it problems, if it keeps the # of rows for example, in another place.. and expects to find that # of rows, the next time it is run.


Maybe Firefox provides an API to do it?
That way we don't bypass it, and don't have any potential to create any problems..

Also thank you mikell for the starting code

Edited by Zohar
Link to comment
Share on other sites

Using SQLite Expert it's very easy to copy the relevant table into a new one in the same database, say you name it saved_moz_cookies. Then you can work on moz_cookies and if anything turns bad when FF is relaunched, you can still go back and restore the old cookies table.

Note: I sometimes do this for myself, directly in original moz_cookies table using the SQL tab in Expert. Never had any issue, thanks to the formidable stability, portability and backward compatibiliy of SQLite. Your copy of FF running in your own smartphone or tablet also comes with an SQLite DB, 100% PC-compatible regardless of the HW/SW platform running it.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...