HACKER Q&A
📣 takinola

Share Your Favorite Bookmarklets


Here are a couple bookmarklets I find myself using often:

Post current web page to HN

   javascript:window.location="http://news.ycombinator.com/submitlink?u="+encodeURIComponent(document.location)+"&t="+encodeURIComponent(document.title)
Find Archive.is link

   javascript:window.location="http://archive.is/newest/"+document.location


  👤 ashtonmeuser Accepted Answer ✓
For anyone stumbling upon this that deals with bookmarklets, I submit bookmarkl.ink[0], a tool I made to ease the maintenance of bookmarklets.

In short, it pulls code from GitHub Gists (which have the benefit of being backed by git repos), transpiles, minifies, bundles, and wraps in an IIFE. It's also got a basic module resolver that allows you to include libraries or remote files.

This allows you to use creature comforts like TS and libraries and maintain code readability while still ending up with the smallest possible bookmarklet. It also allows you to link to a particular version (git hash), present user-defined variables, edit code in an inline editor, etc.

Enjoy!

[0]: https://bookmarkl.ink


👤 SonuSitebot
1. At sitebot, we focus on AI-driven solutions for businesses, but these bookmarklets remind me how simple automation can make life easier. Has anyone experimented with AI-powered bookmarklets, like quick content summarization or auto-filling forms based on context?

2. As someone who works across frontend and backend development, I still find bookmarklets incredibly useful for quick debugging and automation. While browser restrictions have tightened, tools like Tampermonkey or custom browser extensions can still help power users retain control. What are some creative ways you've found to keep bookmarklets alive?


👤 tompark
Oh it's nice to see productivity ones. I mostly use bookmarklets on my phone to fix annoyances bc on a desktop browser you can just open the js console or inspector.

I beefed up the 'kill sticky' one <https://news.ycombinator.com/item?id=32998091> but that's not very interesting. Here are some other ones:

* Re-enable zoom on iPhone (for pages that disable it)

    javascript:document.querySelector('meta%5Bname=viewport%5D').setAttribute('content','width=device-width,initial-scale=1.0,maximum-scale=10.0,user-scalable=1');
* Open same page in new tab with js script tags removed (you must click to allow it to open a new tab)

    javascript:(window.openPageWithoutScripts=async%20function()%7Bconst%20resp=await%20fetch(window.location.href);const%20text=await%20resp.text();const%20doc=new%20DOMParser().parseFromString(text,'text%2Fhtml');doc.querySelectorAll('script').forEach(script=%3Escript.remove());const%20w=window.open();w.document.head.innerHTML=doc.head.innerHTML;w.document.body.innerHTML=doc.body.innerHTML;%7D)(); 
* Show page source

    javascript:(function()%7Bvar%20a=window.open('about:blank').document;a.write('%3C!DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3Ctitle%3ESource%20of%20'+location.href+'%3C/title%3E%3Cmeta%20name=%22viewport%22%20content=%22width=device-width%22%20/%3E%3C/head%3E%3Cbody%3E%3C/body%3E%3C/html%3E');a.close();var%20b=a.body.appendChild(a.createElement('pre'));b.style.overflow='auto';b.style.whiteSpace='pre-wrap';b.appendChild(a.createTextNode(document.documentElement.innerHTML))%7D)();
* Re-enable long-press context menu (for pages that disable it)

    javascript:(function()%7Bdocument.oncontextmenu=null;window.oncontextmenu=null;%7D)();
* Re-enable text selection (for pages that disable it)

    javascript:(function()%7B;document.onselectstart=null;document.onselectchange=null;document.ondragstart=null;document.onmousedown=null;window.ontouchstart=null;window.ontouchend=null;%7D)();

👤 spidersenses
As a Reddit user I'm using this simple replace function to switch to the old.reddit.com version of a page:

javascript:(function(){ if (location.hostname === "www.reddit.com") { location.href = location.href.replace("www.reddit.com", "old.reddit.com"); }})();

Necessary due to Google search results on Reddit leading to the new.reddit.com version of a page which demands a login more often than not.


👤 hboon
Scroll to bottom:

   javascript:(function(){window.scrollTo({top:document.body.scrollHeight,behavior:'smooth'});})();
Scroll to bottom x 10:

    javascript:(function(){%20let%20count%20=%200;%20const%20interval%20=%20setInterval(()%20=>%20{%20window.scrollTo({%20top:%20document.body.scrollHeight,%20behavior:%20'smooth'%20});%20count++;%20if%20(count%20>=%2010)%20clearInterval(interval);%20},%201000);%20})();
Skip YouTube video ad:

    javascript:(function()%7Bvar%20skipButton=document.querySelector('button.ytp-ad-skip-button-modern');if(skipButton)%7BskipButton.click();%7Delse%7Bdocument.querySelector('video').currentTime=document.querySelector('video').duration;%7D%7D)();

👤 perilunar
I hate sticky and fixed page headers, so these two are handy:

Convert fixed position to absolute:

    javascript:(function(){var%20i,%20elements=document.querySelectorAll('body%20*');for%20(i=0;%20i
Convert sticky position to absolute:

    javascript:(function(){var%20i,%20elements=document.querySelectorAll('body%20*');for%20(i=0;%20i
Though looking at them now I should combine and update them.

👤 fouc
Bookmarklets are effectively dead, unless they're extremely simple or you use Firefox. It's kinda ridiculous that they've been effectively blocked by changes to browsers (like chromium-based ones) that make it nearly impossible to run JavaScript from the address bar, along with "Content Security Policy" rules that enable widespread blocking of inline scripts.

It's unfortunate that browser developers want to fully derisk all potential security holes, because that also means removing the choice from the end user. This ends up being security by infantilization.


👤 jackiefeng
give a try TabTab https://tabatb.xyz