// ==UserScript== // @name 巴哈縮圖強化 // @namespace http://tampermonkey.net/ // @version 0.3.11 // @description 狗才用預設縮圖= = // @author SmallYue1 // @match https://forum.gamer.com.tw/B.php* // @downloadURL none // ==/UserScript== var Lists = [], Lists_Img = [], Lists_UnSetted = []; function Find_And_Change() { var Match, Popularity, User, User_LowerCase, Time, Tempt; 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) /*&& (Match[i].className.indexOf('edited') == -1)*/) { if(Match[i].children.length > 2) { Lists.push(Match[i]); Lists_UnSetted.push(""); Lists_Img.push(""); } } } for(i = 0; i < Lists.length; i++) { //if(Lists[i].className.indexOf('edited') == -1) //{ User = Lists[i].children[2].children[1].innerText; User_LowerCase = User.toLowerCase(); Time = Lists[i].children[3].children[0].innerText; Popularity = Lists[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"); for(j = Lists[i].children.length-1; j >1 ; j--) { Lists[i].removeChild(Lists[i].children[j]); } if((Lists[i].className.indexOf('b-imglist-item') != -1)&&(Lists[i].children[1].children.length >1)) { Tempt = Lists[i].children[1].children[0].outerHTML; Lists[i].children[1].children[0].outerHTML = Lists[i].children[1].children[1].outerHTML; Lists[i].children[1].children[1].outerHTML = Tempt; } Lists[i].children[1].prepend(Node_Div_Img_User_NodeTime_NodePopularity); Lists[i].children[1].className=""; if(Lists[i].className.indexOf('b-imglist-item') != -1) { Lists[i].children[1].children[1].className=""; Lists[i].children[1].children[1].setAttribute('style','display:block;margin-top:5px'); } if(Lists[i].children[1].children[1].childElementCount > 1) { Lists[i].children[1].children[1].children[1].setAttribute('style','padding:5px;padding-bottom:0px;margin-right:20px;'); } if(Lists[i].children[1].childElementCount > 2) { Lists[i].children[1].children[2].setAttribute('style','margin-top:5px;margin-bottom:8px'); if(Lists[i].children[1].children[2].children.length > 0) { if(Lists[i].children[1].children[2].children[0].children.length > 0) { if(Lists[i].children[1].children[2].children[0].children[0].localName.indexOf('canvas') == -1) { Lists_Img[i] = Lists[i].children[1].children[2].children[0]; } else { Lists[i].children[1].children[2].children[0].outerHTML = ""; } } else { if(Lists[i].children[1].children[2].children[0].className.indexOf('b-list__img') != -1) { Lists_Img[i] = Lists[i].children[1].children[2].children[0]; } } } else { if(Lists[i].children[1].children[2].className.indexOf('b-list__img') != -1) { Lists_Img[i] = Lists[i].children[1].children[2]; } } } if(Lists[i].children[0].children[2] == null) { var Node_Span = document.createElement('span'); Node_Span.setAttribute('class','b-list__summary__gp b-gp b-gp--normal'); Node_Span.append("0"); Lists[i].children[0].appendChild(Node_Span); } Lists_UnSetted[i] = Node_Div_Img_User_NodeTime_NodePopularity; if(Lists_Img[i] != "") { if(Lists_Img[i].dataset.thumbnail.indexOf("no-img-") != -1) { Lists_Img[i].outerHTML = ""; } else { if((Lists_Img[i].style.length == 0) && (Lists_Img[i].className.indexOf('skeleton') != -1)) { Lists_Img[i].style = 'background-image: url("'+Lists_Img[i].dataset.thumbnail+'");'; Lists_Img[i].className = 'b-list__img'; } if(Lists_Img[i].dataset.thumbnail.indexOf("ytimg") != -1) { Lists_Img[i].parentNode.removeAttribute('href'); Lists_Img[i].parentNode.onclick = function() { this.outerHTML = ''; }; } else { Lists_Img[i].parentNode.removeAttribute('href'); Lists_Img[i].parentNode.onclick = function() { this.outerHTML = ''; }; } } } Lists_UnSetted[i].setAttribute("style","float:left;width:160px;margin-top:5px;margin-bottom:5px;padding-top:"+((Lists_UnSetted[i].parentNode.offsetHeight/2)-((Lists_UnSetted[i].offsetHeight+10)/2))+"px;"); //Lists[i].setAttribute('class','b-list__row b-list-item b-imglist-item edited'); //} } } (function() { 'use strict'; Find_And_Change(); // Your code here... })();