Zyn Rewards Auto Submit

Automatically clicks a specific button on the Zyn site for rewards submission.

  1. // ==UserScript==
  2. // @name Zyn Rewards Auto Submit
  3. // @namespace https://github.com/zimmra/zyn-rewards-autosubmit
  4. // @version 0.4
  5. // @license MIT
  6. // @description Automatically clicks a specific button on the Zyn site for rewards submission.
  7. // @author zimmra
  8. // @match https://us.zyn.com/ZYNRewards/?serialNumber=*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Function to wait for the element to appear
  16. function waitForElement(selector, callback) {
  17. const interval = setInterval(() => {
  18. const element = document.querySelector(selector);
  19. if (element) {
  20. clearInterval(interval);
  21. callback(element);
  22. }
  23. }, 100);
  24. }
  25.  
  26. // Unique selector for the button
  27. const buttonSelector = 'div.flex.relative.shadow-sm.h-64 button.btn.btn--primary.w-112[x-html="buttonLabel"]';
  28.  
  29. // Wait for the button to appear and validate its state before clicking
  30. waitForElement(buttonSelector, (button) => {
  31. if (button && !button.disabled) {
  32. console.log('Clicking the button...');
  33. button.click();
  34. } else {
  35. console.log('Button is disabled or not found.');
  36. }
  37. });
  38. })();