MoveBuy

Moves the "Yes" button on Torn item listings for speedy purchases

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

Advertisement:

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

Advertisement:

// ==UserScript==
// @name         MoveBuy
// @author       realfakedoorz [2302156]
// @match        https://www.torn.com/imarket.php*
// @match        https://www.torn.com/pmarket.php*

// @description  Moves the "Yes" button on Torn item listings for speedy purchases
// @version 0.0.7
// @namespace https://greasyfork.org/users/517405
// ==/UserScript==


const hideSuccess = true; // Hides success box if true

const callbackIMarket = function() {
    if(document.contains(document.querySelector(".items > .active"))){

        var container = document.querySelector (".items > .active");
        var firstTargDiv = container.querySelector (".yes-buy");
        var lastTargDiv = container.querySelector (".buy-link");
        //-- Swap last to first.

        if (firstTargDiv){
            try {
                lastTargDiv.replaceWith(firstTargDiv);
            } catch(error) {
                return
            }
        }
        var endLink = container.querySelector(".yes-buy");
        if (endLink){
            endLink.classList.remove("m-left10");
        }

        if (hideSuccess){
            var succ = container.querySelector(".success-buy");
            succ.style.display = "none";
        }
    }
}

const callbackPMarket = function() {
        if(document.contains(document.querySelector(".ui-state-active"))){

        var container = document.querySelector (".ui-state-active").parentNode;
        var firstTargDiv = container.querySelector (".yes");
        var lastTargDiv = container.querySelector (".wai-btn");
        //-- Swap last to first.

        if (firstTargDiv){
            try {
                lastTargDiv.replaceWith(firstTargDiv);
            } catch(error) {
                return
            }
        }
    }
}

var observerIMarket = new MutationObserver(callbackIMarket);
var observerPMarket = new MutationObserver(callbackPMarket);

var items = document.getElementById("item-market-main-wrap");
var points = document.getElementsByClassName("users-point-sell")[0];

var config = { attributes: true, childList: true, subtree: true };

if (window.location.href.indexOf("imarket") > -1) {
    console.log('Observing for active item selection');
    observerIMarket.observe(items, config);
} else {
    console.log('Changed points market links');
    //observerPMarket.observe(points, config);
    for (var i = 0; i < document.getElementsByClassName("expander").length; i++){
        var hrefTo = (document.getElementsByClassName("expander")[i].getAttribute("href")).split("&")
        var btn = document.getElementsByClassName("expander")[i].getElementsByClassName("action")[0]

        btn.className = "yes wai-support"
        btn.setAttribute("href", (hrefTo[0] + "1&" + hrefTo[1]))

        btn.style.marginTop = "-1px"
        btn.style.paddingTop = "1px"
        btn.style.marginBottom = "-1px"
        btn.style.paddingBottom = "1px"

        var btnInner = btn.getElementsByTagName("button")[0]
        btnInner.className = ""
        btnInner.style.border = "None"
        btnInner.style.background = "Transparent"
}

}