Twitter Image URL replacement

TwitterTL上のimgタグsrcに:orgをつける

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Twitter Image URL replacement
// @namespace    https://greasyfork.org/ja/scripts/13590-twitter-image-url-replacement
// @version      0.4
// @description  TwitterTL上のimgタグsrcに:orgをつける
// @author       kakkou
// @match        https://twitter.com/*
// @exclude      https://twitter.com/search*
// @grant        none
// ==/UserScript==

function repraseURL(node) {
    if ( node.nodeName == "IMG" ) {
        var image = node;
        // 画像クリック時のビューワのURL(:large)は変更しない
        if ( image.src.match(/pbs.twimg.com\/media/) && !image.src.match(/:(?:thumb|large|orig)$/) ) {
            image.src += ':orig';
        }
    }
}

// 最初から読まれてる奴を消す
var elements = document.getElementsByClassName("permalink-container");
for(var i=0; i<elements.length; i++) {
    var imgs = elements[i].getElementsByTagName('img');
    for(var j=0; j< imgs.length; j++) {
        repraseURL(imgs[j]);
    }
}

//Twitterは画像を動的ロードする
document.addEventListener("DOMNodeInserted", function(e){
    repraseURL(e.target);
});