Zohar Posted August 12, 2018 Posted August 12, 2018 (edited) 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 August 12, 2018 by Zohar
TheXman Posted August 12, 2018 Posted August 12, 2018 That functionality is already built into Firefox. There's no fragility in its implementation. It works quite well. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Zohar Posted August 12, 2018 Author Posted August 12, 2018 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)
TheXman Posted August 12, 2018 Posted August 12, 2018 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. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Zohar Posted August 13, 2018 Author Posted August 13, 2018 (edited) 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 August 13, 2018 by Zohar
mikell Posted August 13, 2018 Posted August 13, 2018 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
Zohar Posted August 13, 2018 Author Posted August 13, 2018 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.
Gianni Posted August 13, 2018 Posted August 13, 2018 (edited) 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 August 13, 2018 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
mikell Posted August 13, 2018 Posted August 13, 2018 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()
Zohar Posted August 14, 2018 Author Posted August 14, 2018 (edited) 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 August 14, 2018 by Zohar
Zohar Posted August 16, 2018 Author Posted August 16, 2018 OK I guess I'll take the risk and work directly with the cookies DB..
jchd Posted August 16, 2018 Posted August 16, 2018 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 hereRegExp tutorial: enough to get startedPCRE 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)
Zohar Posted August 17, 2018 Author Posted August 17, 2018 It's great to hear that it's possible to change it and FF is not interfered by it.. I will use this method then.. Thank you very much all And thank you Chimp for the great idea
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now