Greasy Fork is available in English.

Torn Chain Timer Alert and Quick Access

Monitor chain timer and provide quick access to targets in Torn City. Alerts trigger only for chains of 10 hits or more.

  1. // ==UserScript==
  2. // @name Torn Chain Timer Alert and Quick Access
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.7
  5. // @description Monitor chain timer and provide quick access to targets in Torn City. Alerts trigger only for chains of 10 hits or more.
  6. // @author MummaPhucka
  7. // @match https://www.torn.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Torn API Key
  15. const API_KEY = 'OHX3N6jQ93MqTSjn';
  16.  
  17. // Target IDs
  18. const TARGET_IDS = ['200728', '67254', '112024', '583658', '3379302', '3296717', '2615305', '641971', '349224', '936857'];
  19.  
  20. // Torn API Endpoints
  21. const CHAIN_ENDPOINT = `https://api.torn.com/faction/?selections=chain&key=${API_KEY}`;
  22.  
  23. // Notification threshold in seconds (e.g., 300 seconds = 5 minutes)
  24. const ALERT_THRESHOLD = 90;
  25.  
  26. // Minimum chain hits required to trigger alerts
  27. const MIN_CHAIN_HITS = 10;
  28.  
  29. // Inject a custom HTML element
  30. function displayInPage(message) {
  31. const container = document.createElement('div');
  32. container.innerHTML = message;
  33. container.style.position = 'fixed';
  34. container.style.top = '10px';
  35. container.style.right = '10px';
  36. container.style.backgroundColor = '#f44336';
  37. container.style.color = '#ffffff';
  38. container.style.padding = '15px';
  39. container.style.borderRadius = '5px';
  40. container.style.zIndex = '10000';
  41. container.style.fontSize = '14px';
  42. container.style.maxWidth = '300px';
  43. container.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.5)';
  44. document.body.appendChild(container);
  45.  
  46. // Remove the notification after 10 seconds
  47. setTimeout(() => {
  48. container.remove();
  49. }, 10000); // 10 seconds
  50. }
  51.  
  52. // Get Chain Data
  53. async function getChainData() {
  54. try {
  55. const response = await fetch(CHAIN_ENDPOINT);
  56. const data = await response.json();
  57. const chainHits = data.chain.current || 0;
  58. const chainTimer = data.chain.timeout || 0;
  59. return { chainHits, chainTimer };
  60. } catch (error) {
  61. console.error('Error fetching chain data:', error);
  62. return { chainHits: 0, chainTimer: 0 };
  63. }
  64. }
  65.  
  66. // Generate Attack Links for Multiple Targets
  67. function generateAttackLinks() {
  68. return TARGET_IDS.map(id => `<a href="https://www.torn.com/profiles.php?XID=${id}" target="_blank" style="color: #ffffff;">Attack Target ${id}</a>`).join('<br>');
  69. }
  70.  
  71. // Monitor Chain Timer
  72. async function monitorChain() {
  73. while (true) {
  74. const { chainHits, chainTimer } = await getChainData();
  75.  
  76. if (chainHits >= MIN_CHAIN_HITS && chainTimer <= ALERT_THRESHOLD) {
  77. const attackLinks = generateAttackLinks();
  78. const message = `<strong>Chain of ${chainHits} hits is at ${chainTimer} seconds!</strong><br><br>${attackLinks}`;
  79. displayInPage(message);
  80. }
  81.  
  82. await new Promise(resolve => setTimeout(resolve, 60000)); // Wait for 1 minute before checking again
  83. }
  84. }
  85.  
  86. // Start monitoring when the script runs
  87. monitorChain();
  88.  
  89. })();