Bookmarklets, user scripts, etc.

About this page

This is a page for things to modify your browser. These are mainly things that I made for my own use; maybe someone else will want them too. Generally if I have multiple of these types of things (e.g., a bookmarklet and a user script), then they're alternatives that do the same/similar things.

Note that since most of these depend on aspects of how some particular websites work, they might break at any time.

Bookmarklets [B]

Bookmarklets are small pieces of JavaScript code that you can bookmark and then run on other websites to do various things. To use these, bookmark the link (drag it to the bookmark bar, or right-click and then choose "Bookmark this Link"); then when you're on the page you want to use the bookmark on, click on the bookmark.

On iOS (iPhone/iPad/iPod) Safari, it's a bit more complicated: you need to create a bookmark to some website, then edit the bookmark's location. That is, create a bookmark to an ordinary webpage, save it, copy the code, tap the bookmarks icon, tap Edit, delete the URL and then paste the code. (source)

User scripts [G]

These work with the Greasemonkey extension in Firefox. They may also work in other extensions or other browsers; I haven't tested that yet.

User styles [S]

These work with the Stylus extension in Firefox, and possibly other extensions or other browsers. You'll need to copy and paste from the stylesheet to a new style, since I don't know how to make a user style download link.

Contents

(Click the link to go to the section; actual bookmarklet links below.)

No YT Autohide [S][B]

Before: The video controls are covering up the bottom of the video, which in this case, is a text caption that's not a closed caption.  The controls are semi-transparent, but the text under them still isn't very readable.  Caption: "What does that say?"  After: The video controls are opaque and completely outside the video.  The caption is visible; it says "In the 1970s, hovercraft were the future.  So what went wrong?"  Caption: "That's better!"

Fix the new YouTube player so that the playback bar is always visible and doesn't cover up the bottom of the video. Apply the user style (better), OR put the bookmarklet in your bookmarks bar, and click it when you have a video open (the bookmarklet will apply only to that tab). Not guaranteed to work if YouTube changes things again (not guaranteed to work in general; I hope it doesn't break anything, but it seems to work on my computer on both Firefox and Safari).

Known issues:

User style: No YT Autohide

Bookmarklet: No YT Autohide (bookmark this link)

javascript:document.getElementsByClassName('ytp-chrome-bottom')[0].style.bottom='-41px';document.getElementById('movie_player').style.overflow='visible';document.getElementById('placeholder-player').style.marginBottom='51px';document.getElementsByClassName('ytp-gradient-bottom')[0].style.display='none';document.getElementsByClassName('ytp-chrome-bottom')[0].style.opacity='1.0';document.getElementsByClassName('ytp-chrome-bottom')[0].style.background='black';document.getElementById('movie_player').style.cursor='default';undefined;

Beautified:

Play MIDI's [B]

Change all links to .mid or .midi files on the page so that they play the file using midijs.net's script. Useful for MIDIly-challenged computers (*glares in Apple's direction*).

Known issues:

The "Stop MIDIs" bookmarklet stops MIDI files that you've played using the Play MIDIs bookmarklet.

The bookmarklet: Play MIDIs (bookmark this link)

javascript:(function(){var s=document.createElement('script'),l=document.getElementsByTagName('a'),i=0;s.src='//www.midijs.net/lib/midi.js';document.body.appendChild(s);for(;i<l.length;i++)if(l[i].href.match(/\.midi?$/))l[i].onclick=function(){MIDIjs.play(this.href);return%20false;};})();

The other bookmarklet: Stop MIDIs (bookmark this link)

javascript:MIDIjs.stop()

Beautified:

Web archive [G][B]

Display the current page, or (in the user script version) any linked page, in Web Archive. Helpful for if you're browsing an old webpage and come across a bunch of broken links. (Also it offers to save the page if it's not there but available online.)

This is available as a bookmarklet and as a user script. The bookmarklet finds older versions of the current page. The user script adds an item to the context menu to find older versions of the current page or of any link (which is useful if the page now redirects somewhere unhelpful).

The bookmarklet: Web Archive (bookmark this link)

javascript:void(location.href='https://web.archive.org/web/*/'+location.href);

The user script: Web Archive context menu

Enable TVTropes display options [G]

Before: switches labelled "Show Spoilers", "Night Vision", "Sticky Header", and "Wide Load", with all but "Show Spoilers" grayed out; after: the same switches, but none of them are grayed out

On each page in TV Tropes, there are various display options. When you're not logged in, only "Show Spoilers" is enabled, with the other options prompting you to log in if you click them. However, if you enable the options, they work perfectly fine, and there's even perfectly working code to save the options locally like how Show Spoilers works (except for Wide Load, but this script also fixes that). Thus, this script enables those options.

Notes:

The user script: Enable TVTropes display options

Current forum game scores (xkcd forums) [B]

(for example, with the Thread Necromancy Mexican Standoff thread open, clicking this bookmarklet takes you to the Thread Necromancy Mexican Standoff scores)

Go directly to the scores for the forum game you're currently viewing. If not available, go to the list of forum game scorekeepers. This is similar to clicking the link in my signature, except it works even if I haven't posted in the thread recently, and is more reliable when viewing new posts.

The bookmarklet: Forum game scores (bookmark this link)

javascript:if(!function(){var h2=document.getElementsByTagName('h2');if(h2.length==0)return;var a=h2[0].getElementsByTagName('a');if(a.length==0)return;var r=a[0].href.match(/^https?:\/\/(?:www\.)?(?:(?:forums3?|fora)\.xkcd\.com|echochamber\.me)\/viewtopic\.php\?([^#]+)/);if(!r)return;r=('&'+r[1]+'&').match(/&t=(\d+)&/);if(!r)return;return location='https://chridd.nfshost.com/fg/referer?t='+r[1];}())void(location='https://chridd.nfshost.com/fg/');

Beautified:

Disable mobile viewport [B]

Tells mobile browsers to use the default (wide) width and allow zooming, like they do for sites that aren't made for mobile devices. On some websites, this will switch them into desktop layout, rather than mobile layout.

The bookmarklet: Disable mobile viewport (bookmark this link)

javascript:+function(){var m=document.getElementsByTagName("meta");for(var i in m)if(m[i].name=="viewport"){m[i].content="";break}}()

Beautified:

Miscellaneous

Eval Javascript [B]: For browsers that don't allow directly entering javascript: URL's in the address bar and don't have a JavaScript console.

Translate [B]: Translates the current page to English using Google Translate.

Fix Bitbucket scrolling [S]: Bitbucket for no apparent reason has the main content scrolling separately from the window, which makes scrolling work weirdly (scrolling diagonally doesn't work). User style: Fix Bitbucket scrolling