您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
This script automatically buys items at the lowest price on the Shop Search page.
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/30965/203398/Subeta%20Autobuy.js
// ==UserScript== // @name Subeta Autobuy // @namespace http://artees.pw/ // @description This script automatically buys items at the lowest price on the Shop Search page. // @version 0.4 // @author Artees // @match *://subeta.net/user_shops.php/search/shops/* // @match *://subeta.net/shop.php?shopid=* // @match *://subeta.net/explore/pawn.php/buy/* // @grant none // @icon https://subeta.net/favicon.ico // @icon64 https://img.subeta.net/items/accessory_hustlermoneyclip.gif // ==/UserScript== const KEY_AUTOBUY_SOURCE = "autobuySource", KEY_AUTOBUY_NPC = "autobuyNpc"; function autobuy() { setTimeout(buy, 1000); function buy() { var source = sessionStorage[KEY_AUTOBUY_SOURCE]; if (source === undefined) return; sessionStorage.removeItem(KEY_AUTOBUY_SOURCE); var rows = getRows(), items = []; if (rows.length === 0) return; for (var i = 0; i < rows.length; i++) { var row = rows[i], buttons = getButtons(row); if (buttons.length === 0) continue; items.push(row); } function getButtons(e) { return e.getElementsByClassName("btn btn-primary btn-sm"); } items.sort(comparePrices); var item = items[0], isNPC = item.innerText.indexOf("NPC Shop") !== -1; if (isNPC) { sessionStorage[KEY_AUTOBUY_NPC] = source; } var button = getButtons(item)[0], countdown = item.appendChild(document.createElement("P")), nextButton = getButtons(items[1])[0], openCount = 0, clickCount = 4, clickIntervalId = setInterval(click, 1000); countdown.innerText = clickCount.toString(); function click() { clickCount--; countdown.innerText = clickCount.toString(); if (clickCount > 0) return; clearInterval(clickIntervalId); button.click(); if (!isNPC) { var sourceIntervalId = setInterval(openSource, 500); } function openSource() { openCount++; if (button.disabled && nextButton.disabled && openCount < 10) return; open(source, "_self"); clearInterval(sourceIntervalId); } } } function getRows() { return document.getElementsByClassName("row"); } function comparePrices(a, b) { var aPrice = getPrice(a), bPrice = getPrice(b); function getPrice(item) { var itemText = item.innerHTML, end = itemText.indexOf(" sP"), start = itemText.lastIndexOf(">", end) + 1, priceText = replaceAll(itemText.substring(start, end), ",", ""); return parseInt(priceText); } return aPrice - bPrice; } function replaceAll(target, searchValue, replaceValue) { return target.replace(new RegExp(searchValue, 'g'), replaceValue); } back(); function back() { if (getRows().length > 0) return; var source = sessionStorage[KEY_AUTOBUY_NPC]; if (source === undefined) return; sessionStorage.removeItem(KEY_AUTOBUY_NPC); open(source, "_self"); } }