Advertisement
Catalyst08

Untitled

Dec 8th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. // ==UserScript==
  2. // @name TORN: No Confirm
  3. // @namespace dekleinekobini.noconfirm
  4. // @version 4.5.0
  5. // @author DeKleineKobini
  6. // @description No confirm message.
  7. // @match https://www.torn.com/imarket.php*
  8. // @match https://www.torn.com/bazaar.php*
  9. // @match https://www.torn.com/item.php*
  10. // @require https://greasyfork.org/scripts/390917-dkk-torn-utilities/code/DKK%20Torn%20Utilities.js?version=754362
  11. // @grant unsafeWindow
  12. // ==/UserScript==
  13.  
  14. const SETTINGS = {
  15. pages: {
  16. itemmarket: true,
  17. bazaar: true,
  18. items: {
  19. send: true,
  20. usage: true,
  21. equip: true
  22. }
  23. },
  24. compability: {
  25. bazaarfilter: false // only work on filtered pages
  26. }
  27. }
  28.  
  29. initScript({
  30. name: "No Confirm",
  31. logging: "ALL"
  32. });
  33.  
  34. let location = window.location.href;
  35. let params = (new URL(location)).searchParams;
  36. let paramsSpecial = new URLSearchParams(getSpecialSearch());
  37.  
  38. if (location.includes("/imarket.php")) {
  39. dkklog.debug("Detected item market!");
  40. if (SETTINGS.pages.itemmarket) {
  41. ajax((page, json, uri) => {
  42. if (page !== "imarket" || !uri) return;
  43.  
  44. dkklog.info("Started to check in 'itemmarket'.");
  45.  
  46. if (paramsSpecial.get("p") == "shop") observeMutations(document, ".buy-link", true, updateIcons, { childList: true, subtree: true });
  47. else if ($(".buy-item-info-wrap").length) observeMutations($(".buy-item-info-wrap").get(0), ".buy-link", false, updateIcons, { childList: true, subtree: true })
  48.  
  49. function updateIcons() {
  50. dkklog.debug("Replacing icons with instant buy link.");
  51. $(".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>"));
  52. dkklog.trace("Replaced icons with instant buy link.");
  53. }
  54. });
  55.  
  56.  
  57. }
  58. } else if (location.includes("/bazaar.php")) {
  59. dkklog.debug("Detected bazaar!");
  60. if (SETTINGS.pages.bazaar) {
  61. ajax((page, json, uri) => {
  62. if (SETTINGS.loaded || page !== "bazaar" || !uri) return;
  63.  
  64. if (SETTINGS.compability.bazaarfilter && window.scripts.ids.includes("bazaarfilter") && !params.has("filter")) {
  65. dkklog.warn("Not checking in 'bazaar' due to bazaar filter compability!.");
  66. return;
  67. }
  68.  
  69. observeMutations(document, ".items-list", true, (mutations, observer) => {
  70. dkklog.info("Started to check in 'bazaar'.");
  71. observeMutations($(".items-list")[0], ".yes:visible", false, (mutations, observer) => {
  72. dkklog.debug("Clicking confirm button.");
  73. $(".yes:visible").click();
  74. dkklog.trace("Clicked confirm button.");
  75. }, { childList: true, subtree: true });
  76. SETTINGS.loaded = true;
  77. }, { childList: true, subtree: true });
  78. });
  79. }
  80. } else if (location.includes("/item.php")) {
  81. dkklog.debug("Detected inventory!");
  82.  
  83. let checks = [];
  84. if (SETTINGS.pages.items.send) {
  85. dkklog.info("Going to check for item sending.");
  86. checks.push(".send-act[style*='display: block'] .next-act");
  87. }
  88. if (SETTINGS.pages.items.usage) {
  89. dkklog.info("Going to check for item using.");
  90. checks.push(".use-act[style*='display: block'] .next-act[aria-labelledby]");
  91. }
  92. if (SETTINGS.pages.items.equip) {
  93. dkklog.info("Going to check for item equiping.");
  94. checks.push(".unequipped-act[style*='display: block'] .next-act[aria-labelledby]");
  95. }
  96.  
  97. let check = checks.join(", ");
  98. observeMutations($(".category-wrap").get(0), check, false, () => $(check).click(), { childList: true, subtree: true })
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement