TORN - Quick Bazaar

Helps add items to your bazaar quicker by copying the item quantity available and value to the clipboard so you just need to Ctl+V.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         TORN - Quick Bazaar
// @namespace    bazaar
// @version      1.0
// @description  Helps add items to your bazaar quicker by copying the item quantity available and value to the clipboard so you just need to Ctl+V.
// @author       DrCode[1973772]
// @match        https://www.torn.com/bazaar.php
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @grant        GM_setClipboard
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';
    var observer = new MutationObserver(function(mutations) {
        if($("div.amount").length) {
            observer.disconnect();
        }
        $("div.amount").children("input.clear-all").focus(function() {
            var rgx = /.* x(.*)$/g;
            var quantityText = $(this).parent().parent().parent().prev().children(".name-wrap").text();
            var match = rgx.exec(quantityText);
            var quantity = match == null ? 1 : match[1];
            GM_setClipboard(quantity, "text");
        });
        $("div.price").children("div.input-money-group").children("input.clear-all").focus(function() {
            var priceText = $(this).parent().parent().parent().next().children().text().substring(1).replace(/\D/g, '');
            var price = Math.ceil(parseInt(priceText) * 0.9999);
            GM_setClipboard(price, "text");
        });
    });
    var observerTarget = $(".content-wrapper")[0];
    var observerConfig = { attributes: false, childList: true, characterData: false, subtree: true };
    observer.observe(observerTarget, observerConfig);
})();