Twitter Image URL replacement

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

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