Created
June 13, 2018 07:42
-
-
Save cking/8555930a0c55fa831a3620bb8e2e7c91 to your computer and use it in GitHub Desktop.
Preview to full image rewrites
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name URL Rewrite | |
// @namespace Paars | |
// @match *://*/* | |
// @run-at document-start | |
// @grant none | |
// ==/UserScript== | |
const rewrites = [ | |
{ | |
name: "gfycat", | |
test: location => location.host === "thumbs.gfycat.com", | |
action: location => location.href = `https://giant.gfycat.com/${location.pathname.substr(1, location.pathname.indexOf("-") - 1)}.mp4`, | |
}, | |
{ | |
name: "tumblr", | |
test: location => location.host.match(/^\d+\.media\.tumblr\.com$/) && location.pathname.match(/_500\.(\w{3})$/), | |
action: location => location.href = location.href.replace(/_500\.(\w{3})$/, "_1280.$1") | |
} | |
] | |
for (let rewrite of rewrites) { | |
console.log("Checking rewrite for", rewrite.name) | |
if (rewrite.test(window.location)) { | |
console.log("succeeded!") | |
return rewrite.action(window.location) | |
} else { | |
console.log("failed...") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment