Twitter Image URL replacement

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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

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