简体   繁体   中英

clear cookies stored by single website Via bookmarklet

Hi is there anyway to remove all cookies saved by single website ? For example i can view the cookie stored by a particle websites by typing following code in bookmarklet.

javascript:alert(document.cookie);

I know below code but , is there small code that fits in bookmarklet ?

var cookie = document.cookie.split(';');

for (var i = 0; i < cookie.length; i++) {

    var chip = cookie[i],
        entry = chip.split("="),
        name = entry[0];

    document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}

You can use a minifier tool like the Online YUI Compressor which will minify and put all your code in a single line. As an example, your code above turns into the following after minification:

var cookie=document.cookie.split(";");for(var i=0;i<cookie.length;i++){var chip=cookie[i],entry=chip.split("="),name=entry[0];document.cookie=name+"=; expires=Thu, 01 Jan 1970 00:00:01 GMT;"};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM