Auto Click Create Ticket Button with Ticket Limit

Auto-clicks 'Create ticket' unless 3 or more ticket channels exist

  1. // ==UserScript==
  2. // @name Auto Click Create Ticket Button with Ticket Limit
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.0
  5. // @description Auto-clicks 'Create ticket' unless 3 or more ticket channels exist
  6. // @author Yui
  7. // @match *://*/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. const MAX_TICKET_CHANNELS = 3;
  16. let stopClicking = false;
  17.  
  18. function checkTicketChannelCount() {
  19. const elements = document.querySelectorAll(".name__2ea32.overflow__82b15");
  20. let count = 0;
  21.  
  22. elements.forEach(el => {
  23. if (/ticket/i.test(el.textContent)) {
  24. count++;
  25. }
  26. });
  27.  
  28. if (count >= MAX_TICKET_CHANNELS) {
  29. console.log(`[AutoTicket] Found ${count} ticket channels. Stopping click.`);
  30. stopClicking = true;
  31. } else {
  32. stopClicking = false;
  33. }
  34. }
  35.  
  36. function clickButton() {
  37. checkTicketChannelCount();
  38. if (stopClicking) return;
  39.  
  40. const button = document.querySelector(".button__201d5.lookFilled__201d5.colorPrimary__201d5.sizeSmall__201d5.grow__201d5");
  41. if (button) {
  42. button.click();
  43. console.log("[AutoTicket] Create Ticket button clicked.");
  44. } else {
  45. console.log("[AutoTicket] Button not found.");
  46. }
  47. }
  48.  
  49. const observer = new MutationObserver(() => clickButton());
  50. observer.observe(document.body, { childList: true, subtree: true });
  51.  
  52. setInterval(clickButton, 2000);
  53. })();