Bookmarklet Tutorial: Turning Any Webpage into an Editable Tool with JavaScript Bookmarks
This article explains what Bookmarklets are, how to create them in Chrome by converting a normal bookmark into a JavaScript snippet, and showcases practical use‑cases such as making pages editable, highlighting links, applying CSS filters, scrolling, and element hover highlighting, all with concise code examples.
The article introduces Bookmarklets, a special type of browser bookmark whose URL starts with javascript: and contains a self‑executing JavaScript function, allowing scripts to run instantly on the current page without plugins or page reloads.
It explains how to create a Bookmarklet in Google Chrome: save any page as a bookmark, edit the bookmark’s URL to begin with javascript: followed by the desired JavaScript code, and then click the bookmark to execute the script on any site.
javascript:(function(){alert('Hello!');})();Several practical scenarios are demonstrated:
Make any page editable: javascript:document.body.contentEditable='true';document.designMode='on';void 0;
Highlight all links: javascript:[...document.links].forEach(a=>a.style.background='yellow');
Apply rotating CSS filters ("filterer"): javascript:(function(){ const filters = ['none','grayscale(1)','sepia(1)','invert(1)','blur(5px)','contrast(200%)']; let i = 0; setInterval(()=>{document.body.style.filter = filters[i % filters.length]; i++;},2000); })();
Scroll to the bottom of the page: javascript:window.scrollTo(0,document.body.scrollHeight);
Hover‑highlight elements for debugging: javascript:(function(){ const style = document.createElement('style'); style.id = 'hover-highlighter'; style.innerHTML = ` *:hover {outline: 2px solid rgba(0,123,255,0.9) !important;cursor: crosshair !important;} `; document.head.appendChild(style); })();
The article concludes that Bookmarklets provide a lightweight, powerful way to run custom JavaScript on any webpage, encouraging readers to experiment and share their own useful snippets.
Rare Earth Juejin Tech Community
Juejin, a tech community that helps developers grow.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.