Last active
August 29, 2015 14:17
-
-
Save autos/4ba329637d953588cbf2 to your computer and use it in GitHub Desktop.
Imgur to filmot
This file contains hidden or 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 imgur to mirror | |
// @version 0.2 | |
// @description Replaces all imgur links and pictures with mirror links | |
// @include *://*/* | |
// @namespace https://greasyfork.org/users/710 | |
// ==/UserScript== | |
var a = document.getElementsByTagName('a'); | |
for (i=0;i<a.length;i++) { | |
p = /imgur\.com\/([A-Za-z0-9]+\.+[A-Za-z0-9]+)/; | |
res = p.exec(a[i]); | |
if (res!=null) { | |
a[i].href = 'http://i.filmot.org/' + res[1]; | |
} | |
} | |
var p = document.getElementsByTagName('img'); | |
for (i=0;i<p.length;i++) { | |
src = /imgur\.com\/([A-Za-z0-9\/]+\.+[A-Za-z0-9]+)/; | |
res = src.exec(p[i].src); | |
if (res!=null) { | |
p[i].src = 'http://i.filmot.org/' + res[1]; | |
} | |
} | |
var url = document.URL; | |
reg = /imgur\.com\/([A-Za-z0-9]+\.+[A-Za-z0-9]+)?/; | |
res = reg.exec(url); | |
if (res!=null) { | |
if (res[1] != null) | |
location.replace("http://filmot.org/" + res[1]); | |
else | |
location.replace("http://filmot.org/"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment