Chain called hit alert

Helps you from unknownly claiming a faction hit

  1. // ==UserScript==
  2. // @name Chain called hit alert
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description Helps you from unknownly claiming a faction hit
  6. // @author Sil3ntOne [2008029]
  7. // @match https://www.torn.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function(d) {
  12. 'use strict';
  13.  
  14. var currentCount = parseInt(d.querySelector('#barChain [class*="bar-value"]').innerText.split('/')[0]);
  15. console.log(currentCount);
  16.  
  17. var limits = [250, 500, 1000, 2500, 5000, 10000, 25000, 50000, 100000];
  18.  
  19. for(var limit of limits) {
  20. var diff = limit - currentCount;
  21. console.log(diff);
  22. if(diff <= 10 && diff > 0) {
  23. if(localStorage.factionChainHitCallMsgAck != limit) {
  24. var resp = confirm("The " + limit + "th hit might have been called by someone.\nPlease check your faction chat to confirm.\n\nPlease confirm that you have read & acknowleged this message.");
  25. if(resp) {
  26. localStorage.factionChainHitCallMsgAck = limit;
  27. }
  28. }
  29. }
  30. }
  31.  
  32. if(typeof localStorage.factionChainHitCallMsgAck != "undefined") {
  33. if(currentCount >= localStorage.factionChainHitCallMsgAck) {
  34. // Reset the ack after the limit has been crossed.
  35. delete localStorage.factionChainHitCallMsgAck;
  36. }
  37. }
  38. })(document);