CS.RIN.RU - Quality Posts

Only view "quality" posts from verified/pre-defined users in a topic. You can change the verified users, by modifying the verified_users array.

目前為 2016-04-27 提交的版本,檢視 最新版本

// ==UserScript==
// @name         CS.RIN.RU - Quality Posts
// @version      0.1
// @description  Only view "quality" posts from verified/pre-defined users in a topic. You can change the verified users, by modifying the verified_users array.
// @author       Royalgamer06
// @match        http://cs.rin.ru/forum/viewtopic.php?*t=*
// @grant        none
// @namespace https://greasyfork.org/users/13642
// ==/UserScript==

function addJQuery(callback) {
    var script = document.createElement("script");
    script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js");
    script.addEventListener('load', function() {
        var script = document.createElement("script");
        script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
        document.body.appendChild(script);
    }, false);
    document.body.appendChild(script);
}

function addButton() {
    function showQualityPosts() {
        var verified_users = [".Rar",
                              "b00t",
                              "bongsmoke1989",
                              "BzinhoGames",
                              "Christsnatcher",
                              "Demde",
                              "DMN32",
                              "Haoose",
                              "I am AWESOME",
                              "jAck_h!De",
                              "john2s",
                              "kevinyang225",
                              "Lordw007",
                              "Machine4578",
                              "Marti",
                              "Mr.Deviance",
                              "NoWayMan",
                              "pakrat",
                              "prudislav",
                              "RessourectoR",
                              "RezMar",
                              "Royalgamer06",
                              "Sam2k8",
                              "SCS Bot",
                              "sosilent",
                              "Steam006",
                              "steamCooker",
                              "Steve Jobs",
                              "syahmixp",
                              "Testtestom",
                              "Timo654",
                              "toto621",
                              "TwelveCharzzz",
                              "Voksi_Bulgarian"];

        var curr_posts = jQ(".postauthor");
        for (var i = 0; i < curr_posts.length; i++) {
            if (jQ.inArray(curr_posts[i].innerHTML, verified_users) == -1) {
                jQ(curr_posts[i].parentNode.parentNode.parentNode.parentNode).remove();
            }
        }

        //if (document.querySelectorAll("#pageheader > p.gensmall > b > a").length !== 0) {
        //var pages = document.querySelectorAll("#pageheader > p.gensmall > b > a");
        //var lastpage = pages[pages.length-2].innerHTML;

        var currpage = jQ("#pagecontent > table:nth-child(1) > tbody > tr > td.nav > strong:first").text();
        var lastpage = jQ("#pagecontent > table:nth-child(1) > tbody > tr > td.nav > strong:last").text();
        if (lastpage > currpage) {

            jQ("#pagecontent table").last().remove();
            jQ("#pagecontent table").last().remove();

            for (var p = currpage; p < lastpage; p++) {
                jQ.get(location.href + "&start=" + p*15, function(data) {
                    var posts = jQ(data).find(".postauthor");
                    for (var i = 2; i < posts.length-1; i++) {
                        if (jQ.inArray(posts[i].innerHTML, verified_users) > -1) {
                            jQ("#pagecontent").append(posts[i].parentNode.parentNode.parentNode.parentNode);
                        }
                    }
                });
            }
        }
    }
    var button = document.createElement("a");
    button.setAttribute("title", "Quality posts view");
    button.innerHTML = "Quality posts view";
    button.addEventListener("click", showQualityPosts, false);

    jQ("#pagecontent > table:nth-child(2) > tbody > tr > td > table > tbody > tr > td:nth-child(1)").append(" | ").append(button);
}
addJQuery(addButton);