Skip to content

Instantly share code, notes, and snippets.

@Rapptz
Created February 2, 2018 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rapptz/7ea7c57dd55cbcf14728936dd7f94c5d to your computer and use it in GitHub Desktop.
Save Rapptz/7ea7c57dd55cbcf14728936dd7f94c5d to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Hot Reddit Fix
// @namespace Rapptz.Misc
// @author Rapptz
// @description Makes the reddit homepage Hot sort
// @include http://*.reddit.com/*
// @include https://*.reddit.com/*
// @version 1.0
// @run-at document-start
// ==/UserScript==
let url = new URL(window.location);
if(url.pathname == '/') {
// raw homepage, so just redirect
window.location.replace(`${url.href}hot`);
}
function replaceButton() {
// replace best button with /best
let homepage = `${url.protocol}//${url.hostname}/`;
for(let node of document.querySelectorAll(".tabmenu > li > a")) {
if(node.href === homepage) {
node.href = homepage + 'best';
}
}
}
window.addEventListener("load", replaceButton);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment