您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Allows buying items from item market with 1-click
// ==UserScript== // @name TORN: No Confirm Item Market // @namespace http://torn.city.com.dot.com.com // @version 1.0.1 // @description Allows buying items from item market with 1-click // @author IronHydeDragon[2428902] // @match https://www.torn.com/imarket.php* // @license MIT // ==/UserScript== const green = '#678c00'; const greenTranslucent = 'rgba(103, 140, 0, .8)'; const stylesheetHTML = ` <style> .quick-buy { background-color: ${greenTranslucent} } </style>`; function renderStylesheet() { document.head.insertAdjacentHTML('beforeend', stylesheetHTML); } function getPrice(itemEl) { const priceEl = itemEl.querySelector('.cost'); const price = priceEl.childNodes[2].textContent .match(/\d.*/)[0] .trim() .split(',') .join(''); return price; } function buyItemController() { const buyBtnArray = [...document.querySelectorAll('li.buy .buy-link')]; buyBtnArray.forEach((btn) => { const itemEl = btn.closest('li').parentElement.closest('li'); btn.dataset.action = 'buyItemConfirm'; btn.dataset.price = getPrice(itemEl); btn.classList.add('yes-buy'); btn.parentElement.classList.add('quick-buy'); }); } function observerCallback(mutationList, observer) { try { for (const mutation of mutationList) { if ( (mutation.target.id === 'item-market-main-wrap' || mutation.target.classList.contains('buy-item-info-wrap')) && mutation.addedNodes && mutation.addedNodes.length > 0 ) { buyItemController(); } } } catch (error) { console.error(error); } } function createObserver() { const observer = new MutationObserver(observerCallback); observer.observe(document, { attributes: false, childList: true, subtree: true, }); } (async () => { console.log('👍 No confirm item market script is ON!'); renderStylesheet(); createObserver(); })();