[Bzimor] Open All Bazaars

Opens up multiple bazaars in Torn that match your criteria on Bzimor.

  1. // ==UserScript==
  2. // @name [Bzimor] Open All Bazaars
  3. // @namespace https://github.com/TravisTheTechie
  4. // @version 1.0
  5. // @description Opens up multiple bazaars in Torn that match your criteria on Bzimor.
  6. // @author Travis Smith
  7. // @match https://torn.bzimor.dev/items/bazaar/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=bzimor.dev
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. const numbersInUrl = window.location.href.replace(/\D/g, "");
  17.  
  18. if (numbersInUrl == "") return;
  19.  
  20. const itemId = parseInt(numbersInUrl);
  21.  
  22. const controlsDiv = document.createElement("div");
  23. controlsDiv.id = "automation-controls";
  24. controlsDiv.style.paddingTop = "10px";
  25. controlsDiv.style.paddingBottom = "10px";
  26.  
  27. const openAllBtn = document.createElement("button");
  28. openAllBtn.onclick = openAll;
  29. openAllBtn.textContent = "Open all Bazaars";
  30.  
  31. const skipOneDollarLabel = document.createElement("label");
  32. skipOneDollarLabel.textContent = "Skip $1 Entries";
  33. skipOneDollarLabel.style.paddingLeft = "10px";
  34. const skipOneDollarCheckbox = document.createElement("input");
  35. skipOneDollarCheckbox.type = "checkbox";
  36. skipOneDollarCheckbox.checked = localStorage.getItem(`${itemId}_skip_one_dollar`) || false;
  37.  
  38. const maxValueLabel = document.createElement("label");
  39. maxValueLabel.textContent = "Max cost to open";
  40. maxValueLabel.style.paddingLeft = "10px";
  41. const maxValueInput = document.createElement("input");
  42. maxValueInput.type = "number";
  43. maxValueInput.value = localStorage.getItem(`${itemId}_max_value`);
  44.  
  45. [
  46. openAllBtn,
  47. skipOneDollarLabel,
  48. skipOneDollarCheckbox,
  49. maxValueLabel,
  50. maxValueInput,
  51. ].forEach(el => controlsDiv.appendChild(el));
  52.  
  53.  
  54. const stockWrapper = document.querySelector("#stocks_wrapper");
  55.  
  56. if (stockWrapper) {
  57. stockWrapper.insertAdjacentElement('beforebegin', controlsDiv);
  58. }
  59.  
  60.  
  61. function openAll() {
  62. openAllBtn.disabled = true;
  63. const dataRows = document.querySelectorAll("#stocks_wrapper .dataTables_scrollBody tbody tr");
  64. let sleep = 250;
  65.  
  66. // save settings
  67. localStorage.setItem(`${itemId}_skip_one_dollar`, skipOneDollarCheckbox.checked);
  68. if (maxValueInput.value != null) {
  69. localStorage.setItem(`${itemId}_max_value`, maxValueInput.value);
  70. } else {
  71. localStorage.removeItem(`${itemId}_max_value`);
  72. }
  73.  
  74. for(const row of dataRows) {
  75. const elements = row.children[0].children;
  76. const url = elements[elements.length - 1].href;
  77. const playerId = parseInt(url.replace(/\D/g, "")); // replace non-digits
  78. const now = new Date();
  79. const anHourAgo = new Date(now.getTime() - 60 * 60 * 1000); // Current time minus one hour
  80. const value = parseInt(row.children[2].textContent.replace(/\D/g, ""));
  81.  
  82. if (new Date(localStorage.getItem(`visit_${playerId}`) || 0) < anHourAgo) {
  83. if (skipOneDollarCheckbox.checked && value == 1) continue;
  84. if (maxValueInput.value != null && value > maxValueInput.value) continue;
  85.  
  86. localStorage.setItem(`visit_${playerId}`, now);
  87. setTimeout(() => window.open(url, "_blank"), sleep);
  88. sleep += 50;
  89. }
  90. }
  91. setTimeout(() => { openAllBtn.disabled = false; }, sleep + 50);
  92. }
  93. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址