Skip to content

Instantly share code, notes, and snippets.

@deadflowers
Last active February 26, 2025 13:51
Show Gist options
  • Save deadflowers/79661416cb17c72c17936d6003ce5843 to your computer and use it in GitHub Desktop.
Save deadflowers/79661416cb17c72c17936d6003ce5843 to your computer and use it in GitHub Desktop.
Page Info Bookmarklet

Page Info πŸ” JS Bookmarklet

summary:

Simple address bar execution script to display quick info about the current visited page/URL.

usage:

paste in address bar and hit enter, or save as bookmark on your toolbar make sure it starts with javascript: name it whatever you want. easy!

βž• the source

javascript:!(function $(){
    var bs = '\n',
        p = 'origin: ' + location.origin + bs,
        a = 'title: ' + document.title + bs,
        g = 'href: ' + location.href + bs,
        e = 'hash: ' + location.hash + bs,
        i = 'agent: ' + navigator.userAgent + bs,
        n = 'last mod: ' + document.lastModified + bs,
        f = 'current: ' + new Date().toLocaleString() + bs + bs,
        o = 'this bookmarklet: (quine)' + bs + '(' + $ + ')()';

    var str = p + a + g + e + i + n + f + o;
    console.log(str);
    window.alert(decodeURIComponent(str));
})();

note: updated window.alert(decodeURIComponent(escape(str))); as FireFox isn't fond of the call to escape.

Here's a compacted version to highlight and drag to your bookmark bar: javascript:(function $(){var bs='\n',p='origin: '+location.origin+bs,a='title: '+document.title+bs,g='href: '+location.href+bs,e='hash: '+location.hash+bs,i='agent: '+navigator.userAgent+bs,n='last mod: '+document.lastModified+bs,f='current: '+new Date().toLocaleString()+bs+bs,o='this bookmarklet (quine):'+bs+'(' + $ + ')()';var str=p+a+g+e+i+n+f+o;console.log(str);window.alert(decodeURIComponent(str));})();

details

No dependencies besides a compatible browser and a website not employing restrictions on inline scripts and bookmarks like CSP, etc. Output is a simul-display of current page info to both the dev console and alert box. Of all my bookmarklets (even the one that's a terminal stuffed in a bookmark), this one reamins a fav I'm kinda proud of. Why? The self-referential mnemonic of the chain of variables spelling out it's function. I was randomly inspired to employ this lexical inception or poetic echo if you will, because I haven't forgotten U.S. District Judge Lewis Kaplan and the case against 2600 Hacker Quarterly. And nor should you.

Finally and for no reason besides the above and in keeping with the tradition of being self referential, the tail of the program output is...itself! We'd call that a "quine" in computer science, after philosopher Willard Van Orman Quine. Except technically I think it can't take input to be called that, but nobody's calling the cops so we're taking artistic liberties.

But why? There's a story there, as published on one of my 30+ github aliases 8 years ago:

sigh, compulsion i guess. signed up for a service, got distracted, tried some exploits (no ill intent) just feeling the walls you know, found something right away, but the url was too long for screenshot so this was to capture pertinent info for me, or the developers of the app/site via a message box/console summary if I decide to send it to them or if the authorities need context during the routine questioning of potential witnesses and surveying of open tabs on my screen at the time of my untimely and figurative ⚰ death...

Yeah I don't know. It was a very trying time in my life. And writing midnight javascript favlets and bash functions is something I do when I'm anxious haha.

author: Ray Kooyenga aka @deadflowers

site: raykooyenga.com

gh pages rkooyenga.github.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment