Twitter Image URL replacement

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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