Greasy Fork

Greasy Fork is available in English.

Twitch - Images Link to Image

Convert the url images to the real images!

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Twitch - Images Link to Image
// @version      1.0
// @description  Convert the url images to the real images!
// @author       iMaarC
// @match        https://www.twitch.tv/*
// @grant        none
// @namespace http://greasyfork.icu/users/34746
// ==/UserScript==
/* jshint -W097 */
'use strict';

// Your code here...

setInterval(function(){ 

    var img = [".png",".jpg",".gif",".jpeg"];
    var message = document.getElementsByClassName("message");
    
    for(var i = 0; i < message.length; i++){
        if(message[i].parentNode.tagName == 'LI'){
            for(var j = 0; j < img.length; j++){
                if(message[i].children.length != 0){
                    for(var x = 0; x < message[i].children.length; x++){
                        if(message[i].children[x].innerText.indexOf(img[j]) > -1){
                            var imgUrl = message[i].children[x].innerText;
                            message[i].children[x].innerHTML = "";
                            message[i].children[x].innerHTML += "<img src='" + imgUrl +"'></img>"
                        }  
                    }
                }
            }
        }
        else
        {
            console.log("Error - ImgToLink");
        }
    }
}, 500);