Cyclist Ring

Making money by pickpocketing cyclists!

目前为 2024-02-15 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Cyclist Ring
  3. // @namespace microbes.torn.ring
  4. // @version 0.1
  5. // @description Making money by pickpocketing cyclists!
  6. // @author Microbes
  7. // @match https://www.torn.com/loader.php?sid=crimes
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=torn.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. waitForElementToExist('.pickpocketing-root').then(() => {
  17. $('.pickpocketing-root').append(`<div id="cyclist-div"><a id="cyclist-enable-btn" class="torn-btn btn-big">Enable Cyclist Alert</a><br/><br/></div>`);
  18.  
  19. $('#cyclist-enable-btn').click(() => {
  20. $('#cyclist-div').fadeOut();
  21. enabled()
  22. });
  23. });
  24.  
  25. function enabled() {
  26. interceptFetch("torn.com", "/loader.php?sid=crimesData", (response, url) => {
  27. const crimes = response.DB.crimesByType;
  28.  
  29. $('.CircularProgressbar').nextAll().each(function() {
  30. if ($(this).css('background-position-y') == '0px') {
  31. $(this).parent().parent().parent().parent().css("background-color", "#00ff00");
  32. }
  33. });
  34.  
  35. if (isCyclistAvailable(crimes)) {
  36. console.log(crimes);
  37.  
  38. var audio = new Audio('https://audio.jukehost.co.uk/gxd2HB9RibSHhr13OiW6ROCaaRbD8103');
  39. audio.play();
  40. }
  41. });
  42. }
  43.  
  44. function isCyclistAvailable(crimes) {
  45. for (let i = 0; i < crimes.length; i++) {
  46. const crime = crimes[i];
  47. if (crime.title === "Cyclist" && crime.available === true) {
  48. return true;
  49. }
  50. }
  51. return false;
  52. }
  53. })();
  54.  
  55. function interceptFetch(url, q, callback) {
  56. const originalFetch = window.fetch;
  57.  
  58. window.fetch = function() {
  59. return new Promise((resolve, reject) => {
  60. return originalFetch.apply(this, arguments).then(function(data) {
  61. let dataurl = data.url.toString();
  62. if (dataurl.includes(url) && dataurl.includes(q)) {
  63. const clone = data.clone();
  64. if (clone) {
  65. clone.json().then((response) => callback(response, data.url))
  66. .catch((error) => {
  67. console.log("[LoadoutShare][InterceptFetch] Error with clone.json(). Most likely not JSON data.", error)
  68. })
  69. }
  70. }
  71.  
  72. resolve(data);
  73. })
  74. .catch((error) => {
  75. console.log("[LoadoutShare][InterceptFetch] Error with fetch.", error)
  76. })
  77. });
  78. };
  79. }
  80.  
  81. function waitForElementToExist(selector) {
  82. return new Promise(resolve => {
  83. if (document.querySelector(selector)) {
  84. return resolve(document.querySelector(selector));
  85. }
  86.  
  87. const observer = new MutationObserver(() => {
  88. if (document.querySelector(selector)) {
  89. resolve(document.querySelector(selector));
  90. observer.disconnect();
  91. }
  92. });
  93.  
  94. observer.observe(document.body, {
  95. subtree: true,
  96. childList: true,
  97. });
  98. });
  99. }

QingJ © 2025

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