imgur to mirror

Replaces all imgur links and pictures with mirror links

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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/");
}