ams16 ([info]ams16) wrote,
  • Mood: frustrated

javascript/bookmarklet questions

Ok. I want to learn a little javascript so I can debug the following bookmarklet.

javascript:(function(){C=window.cookie.split("; ");
for(d="."+location.host;
d;
d=(""+d).substr(1).match(//..*$/))
for(sl=0;sl<2;++sl)
for(p="/"+location.pathname;
p;
p=p.substring(0,p.lastIndexOf('/')))
for(i in C)
if(c=C[i]){window.cookie=c+"; domain="+d.slice(sl)+";
path="+p.slice(1)+"/"+";
expires="+new Date((new Date).getTime()-1e11).toGMTString()}})();

alert('Cookies deleted')

I know that Safari (which is what I'm using) uses 'window' instead of 'document'. But I don't know why this bookmarklet isn't working. (It is supposed to make all the cookies from the site you are currently visiting expire.)

I've looked (briefly) for a place that simply defines all the objects and sub-objects and the commands that can be used on them in javascript, but I can't find one. (I don't even know if object, sub-object and command are the correct terms. They probably aren't. I mean the things like 'window' and 'window.cookie' and 'window.cookie.split', respectively.)

I'm not even sure I'm parsing the statement correctly. I don't know when the "for" statements end, or the "if" statements.

Any help? Where can I just find a simple definition of everything? Everywhere I go tries to give me a tutorial on javascript, which I don't want. I want something about bookmarklets.

  • Post a new comment

    Error

    Your IP address will be recorded 

  • 1 comments

[info]miekec

November 8 2005, 20:34:08 UTC 6 years ago

Just my $0.02 :
When I throw this into a javascript editor, it complains about the +"; on line 10, and the whole section on line 12 after expires="+ (numbered line below). Maybe the +" and the "+ were on teh same line at some point? Try removing them - my editor stops complaining :)

-- Mieke.

1 javascript:(function(){C=window.cookie.split("; ");
2 for(d="."+location.host;
3 d;
4 d=(""+d).substr(1).match(//..*$/))
5 for(sl=0;sl<2;++sl)
6 for(p="/"+location.pathname;
7 p;
8 p=p.substring(0,p.lastIndexOf('/')))
9 for(i in C)
10 if(c=C[i]){window.cookie=c+"; domain="+d.slice(sl)+";
11 path="+p.slice(1)+"/"+";
12 expires="+new Date((new Date).getTime()-1e11).toGMTString()}})();
13
14 alert('Cookies deleted')
Create an Account
Forgot your login or password?
Facebook Twitter More login options
English • Español • Deutsch • Русский…