javascript bookmark tricks
~ enhance your search experience ;) ~
by Ritz

published at searchlores in September 2002
Updated in October 2004 with a Magical trick by ~S~ Ritz: the EL_KILLA wand!

  by       Petit image    ritz

Did you know you can use javascript in your url-line or in a bookmark to add even more searching functionality to opera [or any other browser]? This is not a tutorial on javascript, there are enough other sites that do that.

ok, so how does it work?

When you type an URL starting with javascript: in your browser, the browser will interpret the line as a piece of javascript. using this technique you can do things to the current webpage [or document, as it is called in javascript] like changing the url in certain ways, or compiling the information in a different way.

a small, and well-known example is:


this small script brings up a messabox displaying the time and date the document was last modified.. good for evaluating the site you are looking at, for example.

there are basically three ways of implementing these small javascripts, or bookmarklets as they are called sometimes:

the BIG (magic) meat (October 2004)

This is an "ad hoc" solution found by ~S~ Ritz on our Seekers' msgboard. It began like this...

...has anybody of you also noticed that a lot of those new, hip, CSS sites with sidebars (like and thousands of others) when you zoom in at them, the letters get bigger, but the middle bar, containing the article you want to read, actually gets a smaller proportion of the screen because Opera is still trying to fit all three bars on the screen.

This is of course not what i want.. anybody got any suggestions for tricks how to tame my browser further?

- ritz

Seems to be because the table has fixed length for the left (and right) crap and only relative length for the middle text you are actually interested in.
A variant of this shit, even more annoying, are those articles "cutted" into 15 sequels, where every time you want to read more you are compelled to open more pages (with their repetitive and annoying correlated crap).
What does Selim do, in cases like

While I agree with you that we should find a more elegant solution, I still use the old school "pasting relevant text" approach:
I just click on the first letter of the article... shift+click on the last one... CTRL+C in memory... tab below to my ultraedit editor... CTRL+V (pasting the lines there)... Format it (through "convert to hard returns")... and read at ease without frills, images, crap.
Takes a coupla seconds, less with a good macro.


And ~S~ Ritz answered with a loud "Bingo!"...

...Took me some time.. but here is the javascript:


var clicks=1;

function info(x){
if(clicks!=0) window.status='click to delete '+x.srcElement.tagName+', shift+click to stop the killing.';

function del(x){
if(clicks!=0 && !x.shiftKey){
window.status=x.srcElement.tagName+' deleted.';
} else {

for(i=0; a.length!=i; i++){
window.status='done. hide any document element by clicking on it. shift+click to abort.';

coded & tested in Opera 7.54 (and Opera 7.23).

the window statusbar should inform you of how to operate the script. basically
just click on any HTML-element you want to kill. then shift-click anywhere if you're done killing.

loads of fun this little script is :)))

fravia, would you mind adding this thingy to my javascript essay? (add it to
the top, since it's one of the most useful so far).

test it, bookmark it, put it on your personal bar, print it out, frame it, hang it above your bed, meditate on it, pray to me, etc..


- ritz


0k - all done, no clicking, good highlighting  (please remember you need to have a Opera browser in order to use this magic wand...
    try it right away (no more clicking, press DEL to delete and ESC to cancel)

    the source:
    var lastEL=document.body;
    var lastStyle=document.body.getAttribute('style');
    var EL_KILLA=1;

    function hover(x){
    window.status='press DEL to delete '+e.tagName+', ESC to cancel.';
    lastEL = e;
    lastStyle = e.getAttribute('style');
    e.setAttribute('style', 'border:2px dashed red');

    function key(x){
    k = x.keyCode;
    if(k==0 && EL_KILLA){
    window.status=lastEL.tagName+' deleted.';


    for(i=0; a.length!=i; i++){

    window.status='done. point and press DEL on any element. ESC to cancel.';

    <daydream>i think it should *in principle* be possible to save the deleted elements
    namespace-URI's in a cookie, have the javascript check for a present cookie
    and immediately delete those elements. at least if the browser supports
    DOM2 .. but on the other hand, my opera throws away cookies on exit, so it's
    not much use.</daydream> ..and maybe it's not possible anyway.

    next version will feature also a sound-effect and an animation of an explosion
    when you press DEL.

    - ritz

Ok, there are few words capable to describe the importance of the above awesome trick by ~S~ Ritz, but, as huge as it is, let it not distract you from the wondrous tricks and codes below :-)

the (rest of) the meat

Ok, here follows a list of javascript-oneliners i've developed so far, copy, bookmark, whatever, abuse for your own pleasure.. some of these might be stolen from but i've only included the scripts that could be used for our purposes here.. please check out their site if you want more bookmarklets [i didn't get all of them to work in Opera, though.]

javascript:void(location.href='http://' + + '/robots.txt')

display robots.txt for this domain.

javascript:if(document.Cracker.length<1){alert('No cookie for this site.')}else{zz=prompt('Cookie for this site:',document.Cracker)}

display cookie for this site


google 100 results. changes the url line so google will give 100 results instead of whatever you have now.'&filter=0'

google no filter. changes the url so google will "repeat the search with the omitted results included."'&filter=0&num=100'

combines the two previous scripts :)

javascript: location.href=''+location.href+'&hl=en'

automatic google translator. google autodetects the source language if you omit the &sl= tag, so all you have to do is run this script over any site in any language google understands to translate it to english. ofcourse you can change &hl=en to any other destination language instead of english.

javascript:a0=prompt('two-letter source language code:'); location.href=''+a0+'&lout=en&url='+location.href

altavista translator. i couldn't get altavista to autodetect the source language, so the user is prompted for it. it still saves time, compared to loading bablefish..

javascript:ttt314=prompt('Highlight words on this site:','');ttt314=ttt314.replace(/\s/g,'+');location.href=''+location.href+'+'+ttt314;

google cache highlight. prompts the user for a set of words to highlight, and looks the current page up in google's cache, with those words highlighted.

javascript: location.href=''+escape(prompt('URL:',''));

pseudo-proxy. of course you can modify this script to work for any "proxy" site that works in this manner. you are prompted for the url.

javascript: location.href=''+escape(location.href);

automatic pseudo-proxy. the user is not prompted, but instead the current url is used.

javascript:aaa314='<html><body>';for(xxx314=0; xxx314<document.links.length; xxx314++){aaa314+='<img src='+document.links[xxx314]+'><br>';};document.write('<center>'+aaa314+'</center></body></html>');void(document.close());

show pictures. makes a new html-pages, that solely consists of <img>-tags. every link on the source page is turned into an <img>-tag, no matter whether it is an actual image or not. very useful if you find an open directory and quickly want to check out all the pictures inside it. [hello pr0n searchers :-P]

javascript:zepp=prompt('cookiestring? [ex: cookieName=cookieValue]','');document.Cracker = zepp;

add cookie. prompts the user for the cookiestring, and then sets the according cookie. good to circumvent pages with very stupid login-protections.
(ahem :-)

javascript:blarg=prompt("unescape what?", ""); xxxx=prompt("okay y0!", unescape(blarg));

unescape. to convert escaped strings to readable text. use this to read those redirection urls full of http%3A// stuff..

javascript:blarg=prompt("escape what?", ""); xxxx=prompt("ok4y y0!", escape(blarg));

escape. to convert characters that are illegal in URLs or whatever, to escaped strings.. useful for messing up scripts and forms [making them accept strings they weren't meant to accept :) ]
(ahem :-)

javascript:href7=location.href;qsplit7=href7.split("?"); asplit7=qsplit7[1].split("&"); for(ind7=0; ind7<asplit7.length&&asplit7[ind7].charAt(0)!="q"; ind7++);clean7=prompt("this be cleaned url", qsplit7[0]+"?"+asplit7[ind7]);location.href=(clean7==null)?href7:clean7;

google url cleaner. this is a MUST for all you people posting on ~S~ board!! :) it strips the current URL [assuming that it is from google] to everything but the bare . makes the url much clearer to read and who needs all that &hl=en&lr=&ie=ISO-8859-1 crap anyway?

Well that's all the javascript-oneliners i've made until now.. every once in a while i think of something new "that should be simpler using javascript" .. perhaps i will post my new findings on ~S~ board, or i will write an additional essay.. anyway, i hope i have given you a nice taste of the power of in-url javascript, so if you have coded a cool piece of bookmarklet, please let me know about it :)

An addition by Jean-Luc (September 2004)

A new function for the HOME Button i.e. the start page of IE:
Increment the URL and open new pages in a for loop.
It work on Images too!


Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main] "Start Page"="javascript:theLink = document.location.href;if(theLink.indexOf(\"javascript\") >= 0 )location.assign(\"about:blank\"); else {r=(theLink.lastIndexOf(\".\")>theLink.length-7);t=r?theLink.lastIndexOf(\".\")-1:theLink.length-1;theNmbr=theLink.substring(t-2,t+1).match(/[0-9]{1,3}/);for(i=0;i<1;i++){q=r?theLink.substring(theLink.lastIndexOf(\".\"),theLink.length):\"\";p=\"000\" + eval(theNmbr++ + '+1');open(theLink.substring(0,t-2+RegExp.index)+p.substring(p.length+RegExp.index-3,p.length) +q)};history.back(-1)}"

Petit image

Whatever [c] you want, we know we did it anyway.