RR Watch Alert

Adds a "Watch Alert" button to the Russian Roulette page in Torn

  1. // ==UserScript==
  2. // @name RR Watch Alert
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Adds a "Watch Alert" button to the Russian Roulette page in Torn
  6. // @author Lollipop :)
  7. // @match https://www.torn.com/page.php*
  8. // @grant GM_xmlhttpRequest
  9. // @connect discord.com
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // EDIT THIS TO USE YOUR OWN WEBHOOK!!!!!!!!
  16. const webhookURL = "https://discord.com/api/webhooks/1354536461567004904/2VMdAn99fqzds-r73uAI3ffXjUKBoKIrUcWxAJBSh3FU3Wlp__k3YEH8L93ESKoQ59Cu";
  17.  
  18.  
  19.  
  20. console.log("Userscript loaded");
  21.  
  22. if (!window.location.href.includes("russianRoulette")) {
  23. console.log("Not on Russian Roulette page, exiting...");
  24. return;
  25. }
  26.  
  27. function getCookie(cname) {
  28. var name = cname + "=";
  29. var ca = document.cookie.split(';');
  30. for(var i = 0; i < ca.length; i++) {
  31. var c = ca[i].trim();
  32. if (c.indexOf(name) == 0) {
  33. return c.substring(name.length, c.length);
  34. }
  35. }
  36. return "";
  37. }
  38.  
  39. function getPlayerInfo() {
  40. try {
  41. let uid = getCookie('uid');
  42. let data = JSON.parse(sessionStorage.getItem('sidebarData' + uid));
  43. if(data && data.user) {
  44. return { id: uid, name: data.user.name };
  45. }
  46. } catch (error) {
  47. console.error("Error getting player info:", error);
  48. }
  49. return { id: null, name: "Unknown Player" };
  50. }
  51.  
  52. function sendWebhook() {
  53. const playerInfo = getPlayerInfo();
  54. if (!playerInfo.id) {
  55. console.error("Could not retrieve player information");
  56. return;
  57. }
  58.  
  59. const payload = {
  60. content: "",
  61. tts: false,
  62. embeds: [{
  63. title: `${playerInfo.name} [${playerInfo.id}]`,
  64. description: `${playerInfo.name} has requested somebody watch their loader!\n\nIf you [know how](https://docs.google.com/document/d/1MFIMYqa_7z9pEsSgF6csljBmZqpG2LlMs3sUMS0KMNk), have time to watch, and have 25E click the button below.\n\n\u200B\n**>>> [👁️ WATCH LOADER 👁️](https://www.torn.com/loader.php?sid=attack&user2ID=${playerInfo.id}) <<<**`,
  65. color: 15409955,
  66. author: {
  67. icon_url: "https://cdn.discordapp.com/icons/1274353457192767489/b877f60af01e678bd608e919f177695f.webp",
  68. name: "Sore Foot Club • Loader Watch Request"
  69. }
  70. }],
  71. components: [{
  72. type: 1,
  73. components: [{
  74. type: 2,
  75. style: 5,
  76. label: "Watch Loader",
  77. url: `https://www.torn.com/loader.php?sid=attack&user2ID=${playerInfo.id}`
  78. }]
  79. }]
  80. };
  81.  
  82. GM_xmlhttpRequest({
  83. method: "POST",
  84. url: webhookURL,
  85. headers: { "Content-Type": "application/json" },
  86. data: JSON.stringify(payload),
  87. onload: response => console.log("Webhook sent successfully", response),
  88. onerror: error => console.error("Error sending webhook", error)
  89. });
  90. }
  91.  
  92. function addButton() {
  93. console.log("Attempting to add button...");
  94. let container = document.querySelector(".linksContainer___LiOTN");
  95. if (!container) return;
  96.  
  97. let lastGamesButton = container.querySelector("[aria-labelledby='last-games']");
  98. if (!lastGamesButton) return;
  99.  
  100. let newButton = document.createElement("a");
  101. newButton.setAttribute("role", "button");
  102. newButton.setAttribute("aria-labelledby", "watch-alert");
  103. newButton.href = "#";
  104. newButton.className = "linkContainer___X16y4 inRow___VfDnd greyLineV___up8VP iconActive___oAum9";
  105. newButton.innerHTML = `
  106. <span class="iconWrapper___x3ZLe iconWrapper___COKJD svgIcon___IwbJV" style="width:36px;height:36px;display:inline-flex;align-items:center;justify-content:center;">
  107. <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 900 1100">
  108. <path fill="#999" d="
  109. M575.637573,463.413391
  110. C589.888123,483.123077 596.375610,504.853241 596.249329,528.767578
  111. C596.083130,560.249756 596.202148,591.733398 596.193542,623.216431
  112. C596.191650,630.057861 596.142578,630.124084 589.160461,630.126038
  113. C523.862305,630.144470 458.564117,630.110229 393.266266,630.249329
  114. C388.366486,630.259766 386.583435,628.941650 386.613678,623.784241
  115. C386.811981,589.970276 386.529755,556.153381 386.758820,522.339844
  116. C387.091644,473.208954 427.192139,428.560089 475.827118,422.642181
  117. C516.562805,417.685486 549.726440,431.173950 575.637573,463.413391
  118. M429.464478,477.002289
  119. C438.526794,465.145874 450.323456,457.075806 464.181152,451.810516
  120. C469.596771,449.752838 471.809723,446.488525 470.602417,442.726227
  121. C469.303528,438.678619 465.082184,437.266357 459.683197,439.073212
  122. C425.088654,450.650635 399.293549,486.461121 399.272736,522.938965
  123. C399.269318,528.928955 401.228058,531.654114 405.626282,531.778625
  124. C409.967438,531.901550 412.481232,528.978516 412.689636,523.349792
  125. C413.318542,506.363983 418.651855,491.067505 429.464478,477.002289
  126. z"/>
  127. <path fill="#999" opacity="1.000000" stroke="none"
  128. d="
  129. M538.000122,643.658936
  130. C559.321228,643.665344 580.142273,643.653320 600.963379,643.683960
  131. C617.312561,643.708008 627.813965,653.982788 628.184326,670.381165
  132. C628.319641,676.374512 628.235901,682.373718 628.196045,688.369873
  133. C628.149231,695.397705 627.377136,696.196838 620.486206,696.201843
  134. C595.334351,696.220276 570.182434,696.207092 545.030579,696.207764
  135. C484.233002,696.209473 423.435394,696.214905 362.637817,696.211365
  136. C354.570740,696.210876 353.792419,695.517700 353.904724,687.320312
  137. C354.004944,680.004456 353.153076,672.646606 354.387512,665.376648
  138. C356.676788,651.894531 366.421875,643.686707 380.092651,643.679382
  139. C432.561798,643.651428 485.030914,643.662415 538.000122,643.658936
  140. z"/>
  141. <path fill="#999" opacity="1.000000" stroke="none"
  142. d="
  143. M728.545654,540.133789
  144. C712.944214,540.145752 697.792725,540.130859 682.641174,540.119995
  145. C679.597717,540.117798 676.553711,539.962341 674.331238,537.527405
  146. C671.940796,534.908386 671.862183,531.755310 672.982971,528.614929
  147. C674.136047,525.383850 677.011597,523.959412 680.063049,523.927246
  148. C696.377197,523.755432 712.695618,523.708618 729.008850,523.912415
  149. C733.353638,523.966675 735.998718,526.747498 736.348755,531.266663
  150. C736.727112,536.151062 734.561462,538.722595 728.545654,540.133789
  151. z"/>
  152. <path fill="#999" opacity="1.000000" stroke="none"
  153. d="
  154. M482.655090,311.000214
  155. C482.666290,305.175995 482.569489,299.848602 482.720490,294.528229
  156. C482.871124,289.218384 485.852631,286.109772 490.516724,286.049316
  157. C495.125885,285.989563 498.098022,288.605194 498.412567,293.806976
  158. C499.387207,309.924927 499.063232,326.066223 498.570892,342.189606
  159. C498.390808,348.088165 495.251007,350.639801 490.072754,350.297791
  160. C485.333649,349.984802 482.772461,347.042755 482.718384,341.449860
  161. C482.621857,331.467346 482.668732,321.483429 482.655090,311.000214
  162. z"/>
  163. <path fill="#999" opacity="1.000000" stroke="none"
  164. d="
  165. M286.998444,523.766602
  166. C292.154846,523.781982 296.817474,523.658997 301.467072,523.850708
  167. C306.661926,524.064941 309.862946,527.212341 309.934479,531.796204
  168. C310.002380,536.147644 306.586517,539.965393 301.591858,540.029236
  169. C285.627777,540.233215 269.658081,540.221069 253.693497,540.038391
  170. C248.479340,539.978821 245.608871,536.639221 245.663406,531.770996
  171. C245.716522,527.031006 248.630371,523.974792 254.067291,523.865112
  172. C264.874084,523.646912 275.687958,523.779419 286.998444,523.766602
  173. z"/>
  174. <path fill="#999" opacity="1.000000" stroke="none"
  175. d="
  176. M345.977936,376.022736
  177. C351.290680,381.344238 356.407196,386.363159 361.406036,391.496643
  178. C365.709229,395.915771 365.908661,400.741699 362.114655,404.255280
  179. C358.792603,407.331818 354.276733,406.851074 350.160553,402.763702
  180. C339.517365,392.195160 328.908508,381.591492 318.351868,370.936554
  181. C313.903198,366.446411 313.556427,361.742462 317.179504,358.259857
  182. C320.881134,354.701752 325.224182,355.192383 329.874451,359.811890
  183. C335.194305,365.096527 340.448120,370.447632 345.977936,376.022736
  184. z"/>
  185. <path fill="#999" opacity="1.000000" stroke="none"
  186. d="
  187. M632.665527,378.665588
  188. C639.264404,372.069000 645.559692,365.667450 651.984253,359.398346
  189. C656.390869,355.098358 660.759277,354.842163 664.215698,358.411713
  190. C667.497314,361.800720 667.139709,366.667603 663.090088,370.755798
  191. C652.326416,381.622192 641.514771,392.441315 630.676025,403.232910
  192. C626.922668,406.969910 622.552551,407.197601 619.209534,404.017365
  193. C615.805420,400.778992 615.777039,395.865295 619.420044,392.015808
  194. C623.646667,387.549561 628.075806,383.274933 632.665527,378.665588
  195. z"/>
  196. </svg>
  197. </span>
  198. <span class="linkTitle____NPyM">Watch Alert</span>
  199. `;
  200.  
  201.  
  202. newButton.addEventListener("click", event => {
  203. event.preventDefault();
  204. console.log("Watch Alert button clicked");
  205.  
  206. // Show a confirm dialog before sending the webhook
  207. let userConfirmed = confirm("Send Watch Request?");
  208. if (userConfirmed) {
  209. sendWebhook();
  210. } else {
  211. console.log("User cancelled the Watch Request.");
  212. }
  213. });
  214.  
  215. container.insertBefore(newButton, lastGamesButton);
  216. console.log("Button added successfully");
  217. }
  218.  
  219. let observer = new MutationObserver((mutations, obs) => {
  220. if (document.querySelector(".linksContainer___LiOTN")) {
  221. addButton();
  222. obs.disconnect();
  223. }
  224. });
  225.  
  226. observer.observe(document.body, { childList: true, subtree: true });
  227. })();

QingJ © 2025

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