TF2Outpost AutoBump

Bumps trade on TF2 Outpost

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name           TF2Outpost AutoBump
// @version        1.0
// @description    Bumps trade on TF2 Outpost
// @include        http://www.tf2outpost.com/trades
// @run-at         document-end
// @grant          none
// @namespace https://greasyfork.org/users/5246
// ==/UserScript==

(function() {
    var RELOAD_MINUTES = 31; // reload every 31 minutes
    var divid = "tf2oab";
    var reload_time, counter;

    function notify(notify) {
        var div = document.getElementById(divid);
        if (!div) {
            var trades = document.getElementById("trades");
            var div = document.createElement("div");
            div.id = divid;
            trades.insertBefore(div, trades.childNodes[0]);
        }
        div.innerHTML = notify;
    }
    
    /*
    Called by the JS Interval counter to reload the page after reload_time
    */
    function showstatus() {
        reload_time -= 1;
        if (reload_time <= 0)
        {
            clearInterval(counter);
            location.reload();
            return;
        }
        var min = Math.floor(reload_time/60);
        var sec = reload_time - min*60;
        notify("TF2 Outpost AutoBump: Reloading page in " +min+ " minutes and "+sec+" seconds...");
    }
    
    function color_anchor(anchor, apply) {
        anchor.parentNode.parentNode.parentNode.parentNode.style.border = apply?"1px solid red":"none";
    }
    
    function bump_trades() {
        var xpr = document.evaluate(".//li/a[@class='trade_bump']/div[@class='icon_bump']", document, null, XPathResult.ANY_TYPE, null);
        var anchor;
        while (anchor = xpr.iterateNext()) {
            anchor = anchor.parentNode;
            if (anchor.getAttribute('data-tradeid'))
                break;
        }
        if (anchor && anchor.getAttribute('data-tradeid')) {
            anchor.scrollIntoView();
            color_anchor(anchor, true);
            setTimeout(function(){
                    color_anchor(anchor, false);
                    anchor.click();
                    setTimeout(bump_trades, 500);
                }, 500);
        } else {
            reload_time = RELOAD_MINUTES*60;
            window.scrollTo(0,0);
            counter = setInterval(showstatus, 1000);
        }
    }
    
    bump_trades();
}).call(this);