Automatically maxes out the amount of money in a ghost trade
当前为
// ==UserScript==
// @name Trade - Max $
// @namespace Titanic_
// @version 1.0
// @description Automatically maxes out the amount of money in a ghost trade
// @license MIT
// @author Titanic_ [2968477]
// @match https://www.torn.com/trade.php*
// @grant window.onurlchange
// ==/UserScript==
if (window.location.href.includes("trade.php#step=addmoney")) {
inputCheck();
}
if (window.onurlchange === null) {
window.addEventListener('urlchange', () => {
inputCheck();
});
}
function inputCheck() {
setTimeout(function() {
if ($('.user-id.input-money').length > 0) {
max();
} else {
setTimeout(inputCheck, 500);
}
}, 300);
}
function max() {
let $inputVisible = document.querySelector(".user-id.input-money");
let $inputHidden = document.querySelectorAll(".user-id.input-money")[1];
let value = parseInt($inputHidden.value) || 0;
let amountOnHand = parseInt($("[class^='value_']").attr("data-money"));
if(amountOnHand > 0) {
value += amountOnHand;
$inputVisible.value = value;
$inputVisible.dispatchEvent(new Event("input", { bubbles: true }));
}
}