how to block a specific cookie from a specific site

3

2

I have started getting quite active on StackOverflow recently, so I've been opening fairly many links to http://jsfiddle.net, but since I'd need to resize the panels regularly to see the specific code posted in the way the code was intended, I usually end up with some pretty weird configurations for the panels. Because I would prefer not having to resize the windows to a more normal setting every time, I would like to block the window_sizes cookie from jsfiddle, but when I tried googling for how to block a single cookie from a specific site, I could find nothing.

I've also tried checking the settings for both Chrome and Firefox, but neither have the option to block a specific cookie, only to block certain domains.

I'm mostly wondering on how to block this specific cookie in Chrome (which is my default browser), but I think it might also be useful for anybody else having the same problem to also include the methods for other browsers too, if that's possible.

joeytje50

Posted 2014-01-30T18:56:14.930

Reputation: 227

Question was closed 2014-02-12T22:50:12.253

@techie007 oh dear, that makes me get afraid this is not possible... – joeytje50 – 2014-01-30T19:31:27.230

I agree, I'm not sure there's an answer to be had. :( – Ƭᴇcʜιᴇ007 – 2014-01-30T19:40:58.313

1Would editing/deleting a specific cookie be a viable workaround? – and31415 – 2014-01-30T22:34:19.827

1@and31415 anything that would automatically prevent a certain cookie from being stored, accessed, or existing. If it's a small userscript, that's fine; if it's a built-in setting, that'd be great of course. I wouldn't like to have to manually delete the cookie every time I want to reset it though. – joeytje50 – 2014-01-30T22:36:07.707

@and31415 could you post the code that worked for you? I am not really able to get it to work. – joeytje50 – 2014-01-31T01:51:47.090

@joeytje50 Sure. – and31415 – 2014-02-01T16:19:36.363

Answers

3

Achievement unlocked - Selective cookie clearing

By default, browsers don't allow such a fine-grained control over cookies: usually you can either block all third-party cookies or block all cookies for a given domain. Blocking everything is not an option because you'll easily end up breaking basic functionality (e.g. user login). In this case you have to resort to userscripts or extensions.


Firefox - userscript solution

This is the code I've come up with. Tested with Firefox 26.0, Greasemonkey 1.14.

// ==UserScript==
// @name        JSFiddlePanelReset
// @namespace   net.jsfiddle.userscripts
// @description Resets panels back to their default size whenever the site is loaded.
// @version     1.0
// @icon        http://jsfiddle.net/favicon.png
// @grant       none
// @include     http://jsfiddle.net/*
// @match       http://jsfiddle.net/*
// ==/UserScript==

(function (){

    // set the domain
    var domain = ".jsfiddle.net";

    // get a date in the past
    var expireDate = new Date(-1).toUTCString();

    // clear the size-related cookie and force it to expire
    document.cookie = "window_sizes=; domain=" + domain + "; path=/; expires=" + expireDate;

})();

Remarks

As pointed out by @Brock Adams in another question, there are major limitations on what Greasemonkey can delete:

  • The cookies you want to delete are on the current page's domain.
  • They are not "Secure cookies".
  • The cookie path (which cannot be detected by Greasemonkey) is the default path, /.
  • No cookies are set by javascript, after the page loads.
  • The thing tracking you really is a "cookie". Many websites use a variety of other techniques, including LSO's, local storage, etc.

References


Chromium-based browsers - extension

While the above userscript does clear the specified cookie, the JSFiddle panels are not reset for whatever reason. Since that's not the type of browser I use, I didn't invest too much time trying to understand why; maybe someone else can shed some light on this. As an alternative you can use the Edit This Cookie extension.

Edit This Cookie

Among other things, this particular extension can block specific cookies. You can filter them by domain, name, and value.

Blocked cookie

References

and31415

Posted 2014-01-30T18:56:14.930

Reputation: 13 382