Greasy Fork

Greasy Fork is available in English.

巴哈縮圖和勇造縮圖

狗才用預設縮圖= =

目前为 2019-04-16 提交的版本,查看 最新版本

// ==UserScript==
// @name         巴哈縮圖和勇造縮圖
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  狗才用預設縮圖= =
// @author       SmallYue1
// @match        https://forum.gamer.com.tw/B.php*
// ==/UserScript==
var Match, Match_Div, Popularity, User, User_LowerCase, Time, Tempt;

function Find_And_Change()
{
    Match = document.getElementsByTagName('tr');
    for(var i = 0; i < Match.length; i++)
    {
        if(Match[i].className.indexOf('b-list__head') != -1)
        {
            for(var j = Match[i].children.length-1; j >0 ; j--)
            {
                Match[i].removeChild(Match[i].children[j]);
            }
        }
        if(Match[i].className.indexOf('b-list__row') != -1)
        {
            if(Match[i].children.length > 2)
            {
                User = Match[i].children[2].children[1].innerText;
                User_LowerCase = User.toLowerCase();
                Time = Match[i].children[3].children[0].innerText;
                Popularity = Match[i].children[2].children[0].innerText
                var NodeImg = document.createElement('img');
                var Node_Div_Img = document.createElement('div');
                var Node_A_Div_Img = document.createElement('a');
                var NodeP_A_Div_Img_User_NodeTime_NodePopularity = document.createElement('p');
                var Node_Div_Img_User_NodeTime_NodePopularity = document.createElement('div');
                var NodeTime = document.createElement('p');
                var NodePopularity = document.createElement('p');
                NodeImg.setAttribute("src", "https://avatar2.bahamut.com.tw/avataruserpic/"+User_LowerCase.split("")[0]+"/"+User_LowerCase.split("")[1]+"/"+User_LowerCase+"/"+User_LowerCase+"_s.png");
                Node_Div_Img.appendChild(NodeImg);
                Node_Div_Img.setAttribute("class", "nav-member_imgbox")
                Node_A_Div_Img.appendChild(Node_Div_Img);
                Node_A_Div_Img.append(User);
                Node_A_Div_Img.setAttribute("class", "topbar_member-home")
                Node_A_Div_Img.setAttribute("href", "https://home.gamer.com.tw/homeindex.php?owner="+User);
                Node_A_Div_Img.setAttribute("target", "_blank");
                NodeTime.appendChild(document.createElement('br'));
                NodeTime.append(" "+Time);
                NodeTime.setAttribute("style", "font-size: 13px");
                NodePopularity.append("互動: "+Popularity.split("/")[0]+" 人氣:"+Popularity.split("/")[1]);
                NodePopularity.setAttribute("style", "font-size: 11px; color:gray;");
                NodeP_A_Div_Img_User_NodeTime_NodePopularity.appendChild(Node_A_Div_Img);
                NodeP_A_Div_Img_User_NodeTime_NodePopularity.appendChild(NodeTime);
                NodeP_A_Div_Img_User_NodeTime_NodePopularity.appendChild(NodePopularity);
                NodeP_A_Div_Img_User_NodeTime_NodePopularity.setAttribute("class","b-list__count__user");
                NodeP_A_Div_Img_User_NodeTime_NodePopularity.setAttribute("style","width:100%;text-align:center;vertical-align:middle;display:inline-block;");
                Node_Div_Img_User_NodeTime_NodePopularity.appendChild(NodeP_A_Div_Img_User_NodeTime_NodePopularity);
                Node_Div_Img_User_NodeTime_NodePopularity.setAttribute("class","TOP-my");
                Node_Div_Img_User_NodeTime_NodePopularity.setAttribute("style","float:left;width:25%;");

                for(j = Match[i].children.length-1; j >1 ; j--)
                {
                    Match[i].removeChild(Match[i].children[j]);
                }
                if((Match[i].className.indexOf('b-imglist-item') != -1)&&(Match[i].children[1].children.length >1))
                {
                    Tempt = Match[i].children[1].children[0].outerHTML;
                    Match[i].children[1].children[0].outerHTML = Match[i].children[1].children[1].outerHTML;
                    Match[i].children[1].children[1].outerHTML = Tempt;
                    //Match[i].children[1].children[1].outerHTML = Match[i].children[1].children[1].children[0].dataset.thumbnail;
                }
                Match[i].children[1].prepend(Node_Div_Img_User_NodeTime_NodePopularity);
                if(Match[i].className.indexOf('b-imglist-item') != -1)
                {
                    Match[i].children[1].children[0].setAttribute("style","float:left;width:25%;"+"padding-top:"+((Match[i].children[1].offsetHeight/2)-(Match[i].children[1].children[0].offsetHeight/1.5))+"px;");
                }
                else
                {
                    Match[i].children[1].children[0].setAttribute("style","float:left;width:18%;"+"padding-top:"+((Match[i].children[1].offsetHeight/2)-(Match[i].children[1].children[0].offsetHeight/1.5))+"px;");
                }
            }
        }
    }
}

function CheckImage()
{
    Match_Div = document.getElementsByTagName('div');
    for(var i = 0; i < Match_Div.length; i++)
    {
        if(Match_Div[i].className.indexOf('skeleton') != -1)
        {
            if(Match_Div[i].style.length == 0)
            {
                Match_Div[i].style = 'background-image: url("'+Match_Div[i].dataset.thumbnail+'");';
                Match_Div[i].className = 'b-list__img';
            }
        }
    }
}

(function() {
    'use strict';
    setInterval(Find_And_Change,100);
    setInterval(CheckImage,1000);
    // Your code here...
})();