fxp first comment bot

be the first to comment everytime.

اعتبارا من 22-05-2019. شاهد أحدث إصدار.

// ==UserScript==
// @name         fxp first comment bot
// @namespace    idk
// @version      0.1
// @description  be the first to comment everytime.
// @author       nktfh100
// @match        https://www.fxp.co.il/*
// @grant    GM_setValue
// @grant    GM_getValue
// @grant    GM_deleteValue
// @noframes
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==

//https://www.fxp.co.il/member.php?u=1089677




function stopButton(){
    $("#stop_button").remove();
    $('body').append('<input type="button" value="Start bot" id="start_button">')
    $("#start_button").css("position", "fixed").css("top", 10).css("left", 10).css('padding', '20px').css('margin', '30px');
    $('#start_button').click(function () { startButton() });

    GM_setValue('state', false);
}

function startButton(){
    $("#start_button").remove();

    $('body').append('<input type="button" value="Stop bot" id="stop_button">')
    $("#stop_button").css("position", "fixed").css("top", 10).css("left", 10).css('padding', '20px').css('margin', '30px');
    $('#stop_button').click(function () { stopButton() });

    GM_setValue('state', 'looking');
    GM_setValue('forum', window.location.href);
    clearInterval(funcLoop);
    funcLoop = setInterval(function() {checkNew();}, 1000);
}

function checkNew() {
    var state_ = GM_getValue('state', false);
    if(state_ == 'looking') {

        //check if first post has 0 comments
        // if it has go to that post. and comment
        //var firstPost = document.getElementById("threads").firstChild;
        //console.debug(firstPost.firstChild);
        //console.debug(firstPost.firstChild.className);
        var count;
        var replays;
        try {
            count = document.querySelector(`ol.threads li.threadbit div.nonsticky ul.threadstats li span.arreplycount a`);
            replays = parseInt(count.innerHTML);
        }
        catch(err) {
            count = document.querySelector(`ol.threads li.threadbit div.nonsticky ul.threadstats li span.arreplycount`);
            replays = parseInt(count.innerHTML);
        }
        console.debug(replays);
        if(replays == 0) {
            console.debug('0!!!');
            //code here by dacurse0
            var o = null;
            var t = "";
            var submitButton = document.getElementById("qr_submit");
            var iframe_ = document.getElementsByTagName("iframe");
            var attr;
            for (var i = 0; i < iframe_.length; i++) {
                if (attr = iframe_[i].getAttribute("title"), "Rich text editor, vB_Editor_QR_editor, press ALT 0 for help." == attr) {
                    o = iframe_[i];
                    break
                }
            }
            var textarea = o.contentDocument.getElementsByClassName("forum")[0];

             textarea.innerHTML = 'ראשון';
             submitButton.click()
            }
    }
    if(state_ == false) {
     clearInterval(funcLoop);
    }
}

var state_ = GM_getValue('state', false);
if (state_ == false) {// if bot is not running
    if (window.location.href.indexOf("forumdisplay.php") > -1) {
        $('body').append('<input type="button" value="Start bot" id="start_button">')
        $("#start_button").css("position", "fixed").css("top", 10).css("left", 10).css('padding', '20px').css('margin', '30px');
        $('#start_button').click(function () { startButton() });

    }
}

var funcLoop;
// states: false: not running, looking:waiting for you posts, posting: posting comment
$(document).ready(function () {
    state_ = GM_getValue('state', false);
    if(state_ == 'looking') {
        if (window.location.href.indexOf("forumdisplay.php") > -1) {

            $('body').append('<input type="button" value="Stop bot" id="stop_button">')
            $("#stop_button").css("position", "fixed").css("top", 10).css("left", 10).css('padding', '20px').css('margin', '30px');
            $('#stop_button').click(function () { stopButton() });
            funcLoop = setInterval(function() {checkNew();}, 1000);
        }else if (window.location.href.indexOf("showthread.php") > -1) {

        }
    }
});
长期地址
遇到问题?请前往 GitHub 提 Issues。