/r/bookmarklets

Photograph via snooOG

A javascript bookmarklet aims to modify the display of a website, but it can do much more.

Post your favorite bookmarklets here.


A javascript bookmarklet aims to modify the display of a website, but it can do much more.

Share and find new bookmarklets to make your surfing easier. Or harder.


Read the subreddit introduction & How-To

Posting Guidelines:

  • Put the javascript code in the self post.
  • Specify if the bookmarklet is specific for [reddit]
  • Specify [Firefox] [Safari] [Chrome]... as needed.
  • Make clear any restrictions or limitations.
  • A link to the original article/author is encouraged.

Hint: 4 spaces before "javascript: ..." will format the text as code.

And you, reader, don't execute scrambled code!

Recommended Subreddits:


/r/bookmarklets

2,054 Subscribers

2

Remove WebArchive Added HTMLs

Bookmarklet to remove webarchive.org Wayback Machine's HTML code from archived page. To remove Wayback Machine's sticky top panel and HTML code comments. Restoring the original site page's HTML code.

The bookmarklet will however, insert a HTML comment containing the URL of the archived page for reference, at the end of the page HTML code.

javascript:/*RemoveWebArchiveAddedHTMLs*/
((a, b, c) => {
  if (!document.querySelector('#wm-ipp-base')) return alert("Not a Wayback Machine archived page.");
  a = document.head;
  while (b = a.firstChild) {
    a.removeChild(b);
    if ((b.nodeType === Node.COMMENT_NODE) && /^\s*end wayback/i.test(b.nodeValue)) break
  }
  a = document.body.firstChild;
  while (a) {
    if ((a.nodeType === Node.COMMENT_NODE) && /^\s*begin wayback/i.test(a.nodeValue)) {
      b = a; c = [a];
      while (b = b.nextSibling) {
        c.push(b);
        if ((b.nodeType === Node.COMMENT_NODE) && /^\s*end wayback/i.test(b.nodeValue)) {
          c.forEach(e => document.body.removeChild(e));
          break
        }
      }
      break
    }
    a = a.nextSibling
  }
  document.removeChild(document.lastChild);
  document.lastChild.nodeValue = location.href
})()
0 Comments
2024/03/13
14:38 UTC

2

Move to new tab

Bookmarklet to move a site to a new tab and close the old one, to start a fresh page view.

Intended to be used for memory leaking sites such as Google Maps which kept consuming more and more memory over time. Reopening it in a new tab and close the old one will free up the leaked memory.

javascript:/*MoveToNewTab*/open(location.href)&&close()
0 Comments
2024/02/27
02:32 UTC

2

Removing Shorts from Youtube's History page

Huge fan of js bookmarks, wish i discovered this sub sooner. Here's my first contribjavascript:(function(){var e=document.querySelectorAll('a[href*="/shorts/"]');e.forEach(function(e){var t=e.parentNode;while(t&&t.parentNode){if("ytd-video-renderer"===t.tagName.toLowerCase()||"ytd-rich-item-renderer"===t.tagName.toLowerCase())break;t=t.parentNode}t&&t.parentNode&&t.parentNode.removeChild(t)})})();

Read more at https://www.reddit.com/r/revancedapp/comments/1as3za0/removing_shorts_from_history_in_web/

https://www.reddit.com/r/youtube/comments/1askhki/how_to_delete_shorts_so_you_can_view_your_actual/

7 Comments
2024/02/16
08:54 UTC

1

Go back to previous reddit

The new interface sucks, this will take you back to the previous interface.

javascript: window.open(document.URL.replace(/\/www./, "/new."), "_self")

edit: I mean the previous UI not old old UI.

7 Comments
2024/02/01
18:02 UTC

6

Redirect staticflickr.com Flickr image to full Flickr image page

javascript:(function(){if(window.location.hostname.indexOf('staticflickr.com')!==-1){var flickrImageID=window.location.pathname.match(/\/(\d+)_/)[1];var flickrPageURL="https://www.flickr.com/photo.gne?rb=1&id="+flickrImageID;window.location.href=flickrPageURL;}else{alert("This bookmarklet only works on staticflickr.com");}})();

https://gist.github.com/jesterjunk/722d9dcfeacc0414e7315846db3215db

screenshot of the Gist page

https://preview.redd.it/8qm00zm850gc1.png?width=1600&format=png&auto=webp&s=77523992c2f814c25d0d3a21a85de98372777d93

0 Comments
2024/02/01
16:35 UTC

2

How to change window title on a window.open?

Hi all, new to the concept of bookmarklets. I have a little bit of JS knowledge but not great. I'm trying to get this example bookmark to open with a custom window title but I can't quite figure out how. Any pointers? This is exactly what I'm using as my bookmark which is opening the window as I want it; I just need to change the window title so I can set it up in a DisplayFusion window position profile.

I might have achieved what I need using this extension, but wouldn't hurt to learn how this can be done from JS. https://chromewebstore.google.com/detail/change-page-title/ebbfpplpmnoblfmdkbicmakmbbjijdpg

javascript:void(window.open('https://player.twitch.tv/?channel=shroud&enableExtensions=true&muted=true&parent=twitch.tv&player=popout&volume=0%27,%27popout_chat%27,%27width=800,height=400%27))

6 Comments
2024/01/16
21:41 UTC

2

Javascript REPL

This bookmarklet will execute the Javascript expression you've entered and show the result. If you for some reason don't want to use the developer console you can use this.
javascript:for((function(){try{eval('')}catch(e){throw alert("Sorry, this webpage has blocked eval(): "+e)}})();;alert((function(a){if(a===null){throw a;}try{return eval(a);}catch(e){return e;}})(prompt())));

0 Comments
2024/01/15
11:43 UTC

2

Running bookmarklets without bookmarking them.

I made a bookmarklet so that you can test it on a page without bookmarking it first:
javascript:void eval((function(x){try{return decodeURI(x)}catch(a){}return x;})(prompt("Try bookmarklets without bookmarking!")).replace(/javascript\:/, ''))
It works most of the time.

(Also, there's a functionality in Firefox called "Browser Console". Executing this in the browser console lets you run the bookmarklet on the entire Window rather than the current tab. But as of my testing most of the bookmarklets will break in such environment.)

1 Comment
2024/01/15
11:33 UTC

3

Hide everything that isn't a Reddit comment.

https://i.imgur.com/pqeOl9E.png

javascript:(function()%7B var style = document.createElement(%27style%27), styleContent = document.createTextNode(%27 * %7B visibility:hidden !important; %7D .md * %7B visibility:visible !important; %7D %27); style.appendChild(styleContent ); var caput = document.getElementsByTagName(%27head%27); caput%5B0%5D.appendChild(style); %7D)();
1 Comment
2024/01/13
19:26 UTC

1

Isthereanydeal.com bookmarklet please

I have created a bookmarklet for isthereanydeal website ( used for checking game prices history ) ? But seems to have run into bit of trouble.

Can anyone help me please write the following bookmarklet to work under Chrome/Chromium?

So this is what i have. Original game url -> https://store.steampowered.com/app/<game_name>

How do i selectively substring only the <game_name> from the original URL ??

My Bookmarklet with errors - javascript:void(window.location="https://isthereanydeal.com/game/?q="+encodeURIComponent(window.location.href)+"/info/");

im trying to get to this -> https://isthereanydeal.com/game/<game_name>/info/

This bookmarklet should be triggered whenever a webpage is viewed and passed through this bookmarklet, will show the search results of isthereanydeal.com for this particular game or (even better) actually opens up the actual the statistics page of the game price.

The bookmarklet should basically pick up the text selected from gamesale page, and search for this selected work word1 and automatically pass it through the website of isthereanydeal.com. Im currently doing this in round about way using some Chrome extension which i dont like and much prefer to use bookmarklet which saves me multiple clicks hopefully.

It seems to be simple but im not sure how to go about with this.

Any solution please? Thank you

2 Comments
2023/12/28
15:39 UTC

1

Convert link to youtu.be format

I'd think somebody that knows this craft of scripting bookmarklets would have a way to change a link to the shortened format from whatever is on the current clipboard.

(I swore this option used to be in the share menu, but now it seems those options are all being made longer with additional tracking data appended and I'm not exactly a fan of that.)

1 Comment
2023/12/17
20:41 UTC

3

Stop timers

Bookmarklets for stopping timeout, interval, and animation-frame based timers. Note: destructive / non resumable. It's not meant for and can not circumvent server tracked timers. Only for pausing/freezing page content changes/progress done by JS timers. Non effective for CSS based animations.

For all timer types:

javascript:/*StopTimers*/(() => {
  "setTimeout,clearTimeout;setInterval,clearInterval;requestAnimationFrame,cancelAnimationFrame".split(";").forEach((pair, tid) => {
    pair = pair.split(",");
    tid = window[pair[0]](() => {}, 0);
    while (tid) window[pair[1]](tid--);
  })
})()

For only timeout timers:

javascript:/*StopTimeoutTimers*/((pair, tid) => {
  pair = "setTimeout,clearTimeout".split(",");
  tid = window[pair[0]](() => {}, 0);
  while (tid) window[pair[1]](tid--);
})()

For only interval timers:

javascript:/*StopIntervalTimers*/((pair, tid) => {
  pair = "setInterval,clearInterval".split(",");
  tid = window[pair[0]](() => {}, 0);
  while (tid) window[pair[1]](tid--);
})()

For only animation-frame timers:

javascript:/*StopAnimationFrameTimers*/((pair, tid) => {
  pair = "requestAnimationFrame,cancelAnimationFrame".split(",");
  tid = window[pair[0]](() => {}, 0);
  while (tid) window[pair[1]](tid--);
})()
1 Comment
2023/12/03
09:23 UTC

3

[Firefox] Inserting a modifier into URLs of varying length

For work, I have to use a ticketing platform that hides the favorites and searchbar whenever you open any link in a new tab. This is visible in a part of the URL missing:

Link opened normally:

https://tool.company.com/nav_to.do?uri=%2Fincident_list.do%blablabla...

Link opened in new tab:

https://tool.company.com/incident_list.do%blablabla...

Essentially, what I need is a bookmark that I can click on to add the needed nav_to.do?uri=%2F to the url, right after the ".com/".

To make matters a bit more complicated, the URL following the domain varies in length a lot, ranging from just over 100 characters to well over 800 or even more sometimes.

5 Comments
2023/11/16
06:06 UTC

1

Open multi-reddit of follows.

On new reddit, if you don't have the list of your subreddits and follows docked on the left then you need to open the menu of subreddits+follows (the v beside your username at the top) before you click the bookmarklet because "progressive web app". Or just use old reddit.

javascript:window.open('https://old.reddit.com/r/'+[...document.querySelectorAll(typeof header=='object'?'li>a.choice[href*="/user/"]':'a[role="menuitem"][aria-label^="u/"]')].map(e=>e.textContent.replace('/','_')).join('+'));
0 Comments
2023/11/09
04:45 UTC

2

set overlay:auto

I tried to use script provided here ~5 years ago to change this:

<html lang="en-US" style="overflow: hidden;" class=" zvwdjxmhp idc0\_349">

into:

<html lang="en-US" style="overflow: **auto**;" class=" zvwdjxmhp idc0\_349">

but it failed, and JS is not my forte.

Can anyone help?

Page is boredpanda - adblock/ublock takes care of everything except lack of scrolling.

3 Comments
2023/11/05
09:18 UTC

3

YouTube Set URL Video Timestamp

Bookmarklet to set/update YouTube URL's video timestamp (i.e. video playback start time) for bookmarking purpose. e.g. when we haven't finished watching a video and need to continue watching it later.

YouTube DOES remember when haven't finished watching a video, and wll set the video playback starting time when we left the video page. BUT it's unreliable and sometimes (if not frequent), it forgets it. Moreover, it won't work if we watch the video in a private/incognito browser tab.

javascript: /*YouTubeSetUrlVideoTimestamp*/
((a, b, c) => {
  if (/^\/(embed\/.{8,}|watch$)/.test(location.pathname)) {
    if (a = window.movie_player) {
      b = new URL(location.href);
      b.searchParams.set("t", (a = Math.floor(a.getCurrentTime())) + "s");
      history.replaceState(null, "", b);
      b = new Date(a * 1000);
      if ((c = (b.getUTCDate() - 1) * 24 + b.getUTCHours()) < 10) c = "0" + c;
      alert(`Video playback timestamp in the URL has been set to at ${a} seconds (${c}${b.toISOString().substr(13, 6)}).`)
    } else alert("Video player is not found.")
  } else alert("Must be on a video player page.")
})()

Minified code:

javascript:/*YouTubeSetUrlVideoTimestamp*/((a,b,c)=>{if(/^\/(embed\/.{8,}|watch$)/.test(location.pathname)){if(a=window.movie_player){b=new URL(location.href);b.searchParams.set("t",(a=Math.floor(a.getCurrentTime()))+"s");history.replaceState(null,"",b);b=new Date(a*1000);if((c=(b.getUTCDate()-1)*24+b.getUTCHours())<10)c="0"+c;alert(`Video playback timestamp in the URL has been set to at${a}seconds(${c}${b.toISOString().substr(13,6)}).`)}else alert("Video player is not found.")}else alert("Must be on a video player page.")})()
0 Comments
2023/10/16
20:46 UTC

5

Say Current Time

I just discovered you can use speech synthesis with bookmarklets

javascript:(function()%7Bfunction%20formatAMPM(date)%20%7B%0A%20%20var%20hours%20%3D%20date.getHours()%3B%0A%20%20var%20minutes%20%3D%20date.getMinutes()%3B%0A%20%20var%20ampm%20%3D%20hours%20%3E%3D%2012%20%3F%20'pm'%20%3A%20'am'%3B%0A%20%20hours%20%3D%20hours%20%25%2012%3B%0A%20%20hours%20%3D%20hours%20%3F%20hours%20%3A%2012%3B%20%2F%2F%20the%20hour%20'0'%20should%20be%20'12'%0A%20%20minutes%20%3D%20minutes%20%3C%2010%20%3F%20'0'%2Bminutes%20%3A%20minutes%3B%0A%20%20var%20strTime%20%3D%20hours%20%2B%20'%3A'%20%2B%20minutes%20%2B%20'%20'%20%2B%20ampm%3B%0A%20%20return%20strTime%3B%0A%7D%0A%0Alet%20utterance%20%3D%20new%20SpeechSynthesisUtterance(formatAMPM(new%20Date()))%3B%0AspeechSynthesis.speak(utterance)%3B%7D)()

I used mdn and stackoverflow to hack together something that sounds practical.

https://stackoverflow.com/questions/8888491/how-do-you-display-javascript-datetime-in-12-hour-am-pm-format

https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis

Someone could be far more immature with this by making it swear or delivering robotic fortunes, or use speech synthesis as an alternative to prompts or console logs, but I thought a rough proof of concept would prove interesting. This does require ES6 support I think.

This also could probably be prone to abuse.

0 Comments
2023/10/02
21:37 UTC

1

Reload Images

Sometimes images may fail to load due to network glitch, overloaded servers, or servers which enforces a strict limit of maximum number of network connections from a client. This bookmarklet forces any images which fail load, to be reloaded. Note: depending on the network condition and/or server, the bookmarklet may need to be executed more than once.

javascript: /*ReloadImages*/
document.querySelectorAll('*').forEach((e, a, b, c) => {
  if (/\burl\(/.test(getComputedStyle(e).backgroundImage)) {
    a = e.attributes.style;
    b = e.style.backgroundImage;
    c = e.style.getPropertyPriority("background-image");
    e.style.setProperty("background-image", "none", "important");
    if (a) {
      e.style.setProperty("background-image", b, c)
    } else e.removeAttribute("style")
  }
  if (e.matches('img,picture source')) {
    ["src", "srcset"].forEach(k => {
      if (a = e.getAttribute(k)) {
        e.setAttribute(k, "about:blank");
        e.setAttribute(k, a)
      }
    })
  }
})
0 Comments
2023/09/16
18:25 UTC

0

Hide posts for Reddit

I'm using old.reddit.com. For many years I've hidden posts with this...

javascript:(function%20f(){var%20u=$("#siteTable%20.hide-button%20a");if(u.length){setTimeout(f,500);u[0].onclick()}%20})()

Today it stopped working. Can anybody fix it?

  1. When I click it - it seems to work. The posts are hidden.

  2. But if I refresh the page - the posts are still there.


Edit

Misery loves company. I hope it's not my bookmark - it's a site-wide error.

CorrectScale comments on Need help cannot hide posts

9 Comments
2023/07/06
23:28 UTC

1

JS to autoselect values?

Can anyone help me please write the following bookmarklet to work under Chrome?

The bookmarklet should be triggered whenever a webpage in the format .domain.com/ is loaded.

In most web forms, there is usually a question or a header and then below there is the element with the different values to choose (e.g. where are you based? US, UK etc)

The bookmarklet should search for word1 in the header and word2 in the values and automatically select word2.

It should work for any kind of drop-down menus or basically any other menu, like bullet points tick boxes etc.

Any solution please? Thank you!

1 Comment
2023/05/31
20:12 UTC

5

Jump video to the end

I wrote this script to remove movies I don't want to finish from "Continue watching" lists from streaming sites. It jumps to the last few seconds, so it gives time to the streaming service to mark it as watched.

javascript:(function() {   var vid = document.getElementsByTagName("video")[0];   vid.currentTime = vid.duration - 5; })();
1 Comment
2023/04/18
23:52 UTC

2

HELP

I've lost an bookmarklet that was the best and i mean best bookmarklet I've seen I found it on github and cannot relocate it all i remember of it is that it when click it shows a simple grey box for a menu and when you open it it should show "cheez" or something like that if you find something like that or have it please link the github page or the bookmarklet in the comments!

7 Comments
2023/01/27
01:19 UTC

6

Open subreddit in new tab

I made this for when you want to look at a subreddit you found online (youtube, an article, ect) without having to open reddit.

add this to your bookmarks:

javascript:(function()%7Bfunction getSelectionText() %7B%0A var text %3D ""%3B%0A if (window.getSelection) %7B%0A text %3D window.getSelection().toString()%3B%0A %7D else if (document.selection %26%26 document.selection.type !%3D "Control") %7B%0A text %3D document.selection.createRange().text%3B%0A %7D%0A return text%3B%0A%7D%0Alet textselected %3D getSelectionText()%3B%0Aif (textselected.slice(0%2C2) %3D%3D "r%2F") %7B%0A window.open("https%3A%2F%2Freddit.com%2F"%2Btextselected%2C '_blank')%3B%0A%7D else %7B%0A alert("not a subreddit!")%3B%0A%7D%7D)()%3B

When you want to use it, just select the name of the subreddit WITH the r/ at the beginning and then click on the bookmark!

0 Comments
2023/01/17
02:40 UTC

2

Google Reverse Image Search querystring has stoped working

0 Comments
2022/11/12
08:17 UTC

Back To Top