Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name TORN: No Confirm
- // @namespace dekleinekobini.noconfirm
- // @version 4.5.0
- // @author DeKleineKobini
- // @description No confirm message.
- // @match https://www.torn.com/imarket.php*
- // @match https://www.torn.com/bazaar.php*
- // @match https://www.torn.com/item.php*
- // @require https://greasyfork.org/scripts/390917-dkk-torn-utilities/code/DKK%20Torn%20Utilities.js?version=754362
- // @grant unsafeWindow
- // ==/UserScript==
- const SETTINGS = {
- pages: {
- itemmarket: true,
- bazaar: true,
- items: {
- send: true,
- usage: true,
- equip: true
- }
- },
- compability: {
- bazaarfilter: false // only work on filtered pages
- }
- }
- initScript({
- name: "No Confirm",
- logging: "ALL"
- });
- let location = window.location.href;
- let params = (new URL(location)).searchParams;
- let paramsSpecial = new URLSearchParams(getSpecialSearch());
- if (location.includes("/imarket.php")) {
- dkklog.debug("Detected item market!");
- if (SETTINGS.pages.itemmarket) {
- ajax((page, json, uri) => {
- if (page !== "imarket" || !uri) return;
- dkklog.info("Started to check in 'itemmarket'.");
- if (paramsSpecial.get("p") == "shop") observeMutations(document, ".buy-link", true, updateIcons, { childList: true, subtree: true });
- else if ($(".buy-item-info-wrap").length) observeMutations($(".buy-item-info-wrap").get(0), ".buy-link", false, updateIcons, { childList: true, subtree: true })
- function updateIcons() {
- dkklog.debug("Replacing icons with instant buy link.");
- $(".buy-link").each((index, el) => $(el).parent().html("<a class='yes-buy t-blue h bold' href='#' data-action='buyItemConfirm' data-id='" + $(el).attr("data-id") + "' data-item='0'><span class='buy-icon'></span></a>"));
- dkklog.trace("Replaced icons with instant buy link.");
- }
- });
- }
- } else if (location.includes("/bazaar.php")) {
- dkklog.debug("Detected bazaar!");
- if (SETTINGS.pages.bazaar) {
- ajax((page, json, uri) => {
- if (SETTINGS.loaded || page !== "bazaar" || !uri) return;
- if (SETTINGS.compability.bazaarfilter && window.scripts.ids.includes("bazaarfilter") && !params.has("filter")) {
- dkklog.warn("Not checking in 'bazaar' due to bazaar filter compability!.");
- return;
- }
- observeMutations(document, ".items-list", true, (mutations, observer) => {
- dkklog.info("Started to check in 'bazaar'.");
- observeMutations($(".items-list")[0], ".yes:visible", false, (mutations, observer) => {
- dkklog.debug("Clicking confirm button.");
- $(".yes:visible").click();
- dkklog.trace("Clicked confirm button.");
- }, { childList: true, subtree: true });
- SETTINGS.loaded = true;
- }, { childList: true, subtree: true });
- });
- }
- } else if (location.includes("/item.php")) {
- dkklog.debug("Detected inventory!");
- let checks = [];
- if (SETTINGS.pages.items.send) {
- dkklog.info("Going to check for item sending.");
- checks.push(".send-act[style*='display: block'] .next-act");
- }
- if (SETTINGS.pages.items.usage) {
- dkklog.info("Going to check for item using.");
- checks.push(".use-act[style*='display: block'] .next-act[aria-labelledby]");
- }
- if (SETTINGS.pages.items.equip) {
- dkklog.info("Going to check for item equiping.");
- checks.push(".unequipped-act[style*='display: block'] .next-act[aria-labelledby]");
- }
- let check = checks.join(", ");
- observeMutations($(".category-wrap").get(0), check, false, () => $(check).click(), { childList: true, subtree: true })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement