Enable Attack Button on Torn Profile Page

Enables a disabled button on Torn profile page and redirects to the attack page when the button is clicked

当前为 2023-07-15 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Enable Attack Button on Torn Profile Page
  3. // @namespace https://lordrhino.co.uk/
  4. // @version 1.0
  5. // @description Enables a disabled button on Torn profile page and redirects to the attack page when the button is clicked
  6. // @match https://www.torn.com/profiles.php?XID=*
  7. // ==/UserScript==
  8.  
  9. (function() {
  10. 'use strict';
  11.  
  12. function enableButton(button) {
  13. if (button && button.classList.contains('disabled')) {
  14. button.classList.remove('disabled');
  15. button.classList.add('active');
  16. button.removeAttribute('aria-disabled');
  17. button.removeAttribute('href');
  18. button.addEventListener('click', handleButtonClick);
  19. }
  20. }
  21.  
  22. function handleButtonClick(event) {
  23. event.preventDefault();
  24. // Get the user ID from the button's ID
  25. const userID = event.target.id.replace('button0-profile-', '');
  26. // Redirect to the attack page with the user ID
  27. window.location.href = `https://www.torn.com/loader.php?sid=attack&user2ID=${userID}`;
  28. }
  29.  
  30. const checkButtonAvailability = setInterval(function() {
  31. const buttons = document.querySelectorAll('[id^="button0-profile-"]');
  32. if (buttons.length > 0) {
  33. clearInterval(checkButtonAvailability);
  34. buttons.forEach(enableButton);
  35. }
  36. }, 1000);
  37. })();