fxp first comment bot

be the first to comment everytime.

Version vom 22.05.2019. Aktuellste Version

// ==UserScript==
// @name         fxp first comment bot
// @namespace    idk
// @version      0.2
// @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') {

        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!!!');
            GM_setValue('state','posting');
            var post_ = document.querySelector(`ol.threads li.threadbit div.nonsticky div.threadinfo div.inner h3.threadtitle a.title`);
            var startTime = new Date();
            GM_setValue('startTime', startTime);
            post_.click();
        }

    }
    if(state_ == false) {
     clearInterval(funcLoop);
    }
}

function goToForum() {

}

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) {

        }
    }
    if(state_ == 'posting') {
        var endTime = new Date();
        var timeDiff = endTime - GM_getValue('startTime', endTime); //in ms

        timeDiff /= 1000;

        var seconds = Math.round(timeDiff);
        if(seconds < 40) {
            try {
                //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()

                GM.setValue('state', 'looking');

                window.location.href = GM_getValue('forum', 'https://www.fxp.co.il/');
            }
            catch(err) {
                GM.setValue('state', 'looking');
                window.location.href = GM_getValue('forum', 'https://www.fxp.co.il/');
            }
        }
    }else {//turn off bot
        GM_setValue('state', false);
    }
});
长期地址
遇到问题?请前往 GitHub 提 Issues。