Greasy Fork is available in English.

巴哈姆特之互動改回回覆

把巴哈亂改的互動調整回原本的回覆

От 2019-04-13 14:57:44 UTC. Виж последната версия.

// ==UserScript==
// @name         巴哈姆特之互動改回回覆
// @description  把巴哈亂改的互動調整回原本的回覆
// @namespace    nathan60107
// @version      1.0
// @author       nathan60107(貝果)
// @homepage     https://home.gamer.com.tw/homeindex.php?owner=nathan60107
// @include      https://forum.gamer.com.tw/B.php*
// ==/UserScript==

//=====================以下內容可修改====================

var mode = 1;//mode = 1代表變更為"回覆數/人氣",mode = 2代表變更為"回覆數/首樓留言數/人氣"。

//=====================以上內容可修改====================

function replace(){
    var list = document.getElementsByClassName("b-list__row");
    if(list.length!=0) {
        var head = document.getElementsByClassName("b-list__head")[0];
        head.outerHTML = head.outerHTML.replace("互動", "回覆"+(mode==2?" / 留言":""));

        for(var i=0; i<list.length; i++){
            if(list[i].children[3]==null)continue;
            var reply = list[i].children[3].outerHTML.match(/tnum=[0-9]+&/)[0];
            reply = parseInt(reply.substr(5, reply.length-6))-1;
            var interactive = list[i].children[2].outerHTML.match(/<span>[0-9]+<\/span>\//)[0];
            interactive = parseInt(interactive.substr(6, interactive.length-14));

            list[i].children[2].outerHTML = list[i].children[2].outerHTML.replace(/<span>[0-9]+<\/span>\// , "<span>"+reply.toString()+"</span>/"+(mode==2?"\n<span>"+(interactive-reply).toString()+"</span>/":""));
        }
    }else{
        setTimeout(function(){replace();}, 1000);
    }
}

function replace2(){
    var list = document.getElementsByClassName("b-list__row");
    if(list.length!=0) {
        var head = document.getElementsByClassName("b-list__head")[0];
        head.outerHTML = head.outerHTML.replace("互動", "回覆 / 留言");
        for(var i=0; i<list.length; i++){
            if(list[i].children[3]==null)continue;
            var reply = list[i].children[3].outerHTML.match(/tnum=[0-9]+&/)[0];
            reply = parseInt(reply.substr(5, reply.length-6))-1;
            var interactive = list[i].children[2].outerHTML.match(/<span>[0-9]+<\/span>\//)[0];
            interactive = parseInt(interactive.substr(6, interactive.length-14));
            list[i].children[2].outerHTML = list[i].children[2].outerHTML.replace(/<span>[0-9]+<\/span>\// , "<span>"+reply.toString()+"</span>/\n<span>"+(interactive-reply).toString()+"</span>/");
        }
    }else{
        setTimeout(function(){replace2();}, 1000);
    }
}

(function() {
    'use strict';
    setTimeout(function(){replace();}, 1000);
})();