gplinks auto-skip

Remove the adclick nag and auto-click the buttons.

  1. // ==UserScript==
  2. // @name gplinks auto-skip
  3. // @author BlazeFTL
  4. // @namespace http://tampermonkey.net/
  5. // @description Remove the adclick nag and auto-click the buttons.
  6. // @version 2.3
  7. // @match *://*/*
  8. // @supportURL https://github.com/uBlockOrigin/uAssets/discussions/27472#discussioncomment-12725221
  9. // @icon https://www.google.com/s2/favicons?domain=gplinks.com
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15. const button1 = document.querySelector('#VerifyBtn');
  16. const button2 = document.querySelector('#NextBtn');
  17. if (button1 && button2){
  18.  
  19.  
  20. const INTERVAL_2S = 2000;
  21. const INTERVAL_1S = 1000;
  22. const smileyExists = !!document.querySelector('.SmileyBanner');
  23.  
  24. // 1. Set cookie_pub_plan_id to 12
  25. window.cookie_pub_plan_id = 12;
  26.  
  27. // 2. Create and focus fake iframe ONCE
  28. (function focusIframeOnce() {
  29. const i = document.createElement('iframe');
  30. i.style = 'height:0;width:0;border:0;';
  31. i.id = 'a';
  32. document.body.appendChild(i);
  33. i.focus();
  34. setTimeout(() => window.focus(), 500); // Refocus main window shortly after
  35. })();
  36.  
  37. // 3. Ensure ad cookie is set
  38. function SetAdCookie() {
  39. const expireTime = new Date(new Date().getTime() + 2 * 60 * 1000); // 2 mins
  40. document.cookie = `adexp=1; path=/; expires=${expireTime.toUTCString()}`;
  41. }
  42. SetAdCookie();
  43.  
  44. // 4. Click logic
  45. let verifyClicked = false;
  46. let nextClicked = false;
  47.  
  48. function clickIfVisible(el) {
  49. if (el && el.offsetParent !== null) {
  50. el.click();
  51. return true;
  52. }
  53. return false;
  54. }
  55.  
  56. function clickWithRetry(selector, flagName, callback) {
  57. const el = document.querySelector(selector);
  58. if (!el) return;
  59.  
  60. if (!window[flagName]) {
  61. const clicked = clickIfVisible(el);
  62. if (clicked) {
  63. window[flagName] = true;
  64. if (callback) callback();
  65. } else {
  66. setTimeout(() => clickWithRetry(selector, flagName, callback), 1000);
  67. }
  68. }
  69. }
  70.  
  71. function clickNextAndCheckHash() {
  72. clickWithRetry('.NextBtn', 'nextClicked', () => {
  73. setTimeout(() => {
  74. if (window.location.href.endsWith('#')) {
  75. // Click again if URL ends with #
  76. window.nextClicked = false;
  77. clickWithRetry('.NextBtn', 'nextClicked');
  78. }
  79. }, 1500);
  80. });
  81. }
  82.  
  83. if (smileyExists) {
  84. const verifyBtn = document.querySelector('#VerifyBtn');
  85. const placeholder = document.createElement('div');
  86. placeholder.style.color = 'black';
  87. placeholder.style.fontWeight = 'bold';
  88. placeholder.id = 'countdown-replace';
  89. verifyBtn.parentNode.insertBefore(placeholder, verifyBtn);
  90. verifyBtn.style.display = 'none';
  91.  
  92. let countdown = 15;
  93. placeholder.innerText = `Please wait ${countdown} seconds`;
  94.  
  95. const timer = setInterval(() => {
  96. countdown--;
  97. placeholder.innerText = `Please wait ${countdown} seconds`;
  98.  
  99. if (countdown <= 0) {
  100. clearInterval(timer);
  101. verifyBtn.style.display = 'inline-block';
  102. placeholder.remove();
  103. clickWithRetry('#VerifyBtn', 'verifyClicked');
  104. setTimeout(clickNextAndCheckHash, 1000);
  105. }
  106. }, INTERVAL_1S);
  107. } else {
  108. setTimeout(() => {
  109. clickWithRetry('#VerifyBtn', 'verifyClicked');
  110. setTimeout(clickNextAndCheckHash, 1000);
  111. }, 16000);
  112. }
  113. }
  114. })();