Das' OC checker

adds color highlights to OCs where members do not fulfill the success chance requirements

  1. // ==UserScript==
  2. // @name Das' OC checker
  3. // @version 0.1
  4. // @namespace https://github.com/DasLewis
  5. // @description adds color highlights to OCs where members do not fulfill the success chance requirements
  6. // @icon https://www.google.com/s2/favicons?sz=64&domain=torn.com
  7. // @author DasLewis [2524294]
  8. // @license MIT License
  9. // @match https://www.torn.com/factions.php*
  10. // @grant none
  11. // ==/UserScript==
  12. //DISCLAIMER: THIS SCRIPT USES SOME APPROACHES FROM "Torn Pickpocketing Colors" by Korbrm [2931507]
  13. //https://greasyfork.org/en/scripts/477536-torn-pickpocketing-colors
  14.  
  15.  
  16. (function() {
  17. 'use strict';
  18. const scriptPrefix = "Das_OC_checker";
  19. const colorCodeBad = "#B22222";
  20.  
  21. //success chance required for each OC level
  22. const ocRequirements = {
  23. "1" : 80,
  24. "2" : 80,
  25. "3" : 80,
  26. "4" : 80,
  27. "5" : 80,
  28. "6" : 80,
  29. "7" : 70,
  30. "8" : 60,
  31. "9" : 80,
  32. "10" : 80
  33. };
  34.  
  35. function updateOCMarkers() {
  36. const url = window.location.href;
  37. if (!url.includes("#/tab=crimes")){
  38. return;
  39. }
  40.  
  41. const ocElements = document.querySelectorAll('.wrapper___U2Ap7:not(.processed)');
  42. ocElements.forEach(ocElement => {
  43. const ocLevel = ocElement.querySelector('.levelValue___TE4qC').textContent.trim();
  44. const ocName = ocElement.querySelector('.panelTitle___aoGuV').textContent.trim();
  45. const ocParticipants = ocElement.querySelectorAll('.wrapper___Lpz_D');
  46. ocParticipants.forEach(participantWrapper => {
  47. if (!participantWrapper.classList.contains("waitingJoin___jq10k")) {
  48. const participantSuccess = participantWrapper.querySelector('.successChance___ddHsR').textContent.trim();
  49. const participantName = participantWrapper.querySelector('.badge___E7fuw').querySelectorAll('.honor-text')[1].textContent.trim();
  50. if (ocRequirements[ocLevel] > participantSuccess) {
  51. //console.log(`User "${participantName}" in OC "${ocName}" (Level ${ocLevel}) does not meet requirements. (${participantSuccess}/${ocRequirements[ocLevel]})`);
  52. ocElement.querySelector('.wrapper___eWVgj').style.backgroundColor = colorCodeBad;
  53. participantWrapper.querySelector('.slotHeader___K2BS_').style.backgroundColor = colorCodeBad;
  54. }
  55. }
  56. })
  57.  
  58. ocElement.classList.add('processed');
  59. });
  60. }
  61.  
  62. updateOCMarkers();
  63. setInterval(updateOCMarkers, 1000);
  64. })();