Gplinks Bypass

Bypassing gplinks.co

  1. // ==UserScript==
  2. // @name Gplinks Bypass
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description Bypassing gplinks.co
  6. // @match *://*/*
  7. // @author Jayasurya Mailsamy
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14.  
  15. // Function to remove scripts from the head
  16. function removeHeadScripts() {
  17. const head = document.head || document.getElementsByTagName('head')[0];
  18. const scripts = head.querySelectorAll('script');
  19.  
  20. scripts.forEach(script => {
  21. script.parentNode.removeChild(script);
  22. });
  23. }
  24.  
  25. // Function to set up a MutationObserver to detect script tags being added to the head
  26. function observeHeadForScripts() {
  27. const head = document.head || document.getElementsByTagName('head')[0];
  28.  
  29. // Create a MutationObserver to watch for changes in the head element
  30. const observer = new MutationObserver(mutations => {
  31. mutations.forEach(mutation => {
  32. mutation.addedNodes.forEach(node => {
  33. if (node.tagName === 'SCRIPT') {
  34. node.parentNode.removeChild(node);
  35. }
  36. });
  37. });
  38. });
  39.  
  40. // Observe the head element for child list changes
  41. observer.observe(head, {
  42. childList: true
  43. });
  44.  
  45. // Also remove existing script elements immediately
  46. removeHeadScripts();
  47. }
  48.  
  49. // Function to check for the specific script tag
  50. function checkForScript() {
  51. const scriptSrc = 'https://api.gplinks.com/track/js/main.js?2.7';
  52. const scripts = document.getElementsByTagName('script');
  53.  
  54. for (let i = 0; i < scripts.length; i++) {
  55. if (scripts[i].src === scriptSrc) {
  56.  
  57. // Proceed to make POST requests and redirect
  58. makePostRequestsAndRedirect();
  59. break;
  60. }
  61. }
  62. }
  63.  
  64. // Function to get the value of a specific cookie
  65. function getCookie(name) {
  66. const value = `; ${document.cookie}`;
  67. const parts = value.split(`; ${name}=`);
  68. if (parts.length === 2) return parts.pop().split(';').shift();
  69. return null;
  70. }
  71.  
  72. // Function to alert selected cookies
  73. function alertSelectedCookies() {
  74. const lid = getCookie("lid");
  75. const pid = getCookie("pid");
  76. const plid = getCookie("plid");
  77. const vid = getCookie("vid");
  78.  
  79. let message = 'Cookies:\n';
  80. if (lid) message += `lid: ${lid}\n`;
  81. if (pid) message += `pid: ${pid}\n`;
  82. if (plid) message += `plid: ${plid}\n`;
  83. if (vid) message += `vid: ${vid}\n`;
  84.  
  85. if (message === 'Cookies:\n') {
  86. message = 'No relevant cookies found.';
  87. }
  88.  
  89. alert(message);
  90. }
  91.  
  92. // Function to make POST requests
  93. function setVisitor(status, impressions, visitorId) {
  94. return $.ajax({
  95. type: "POST",
  96. url: "https://gplinks.com/track/data.php",
  97. data: {
  98. request: "setVisitor",
  99. status: status,
  100. imps: impressions,
  101. vid: visitorId,
  102. },
  103. dataType: "json",
  104. });
  105. }
  106.  
  107. // Function to handle POST requests and redirect
  108. function makePostRequestsAndRedirect() {
  109. const vid = getCookie("vid"); // Assuming you want to use the cookie value for visitorId
  110. const cookie_pub_id = getCookie("pid");
  111. const cookie_link_id = getCookie("lid");
  112. if (!vid || !cookie_pub_id || !cookie_link_id) {
  113. alert('Missing required cookies for POST requests and redirect.');
  114. return;
  115. }
  116.  
  117. // Perform three POST requests with different parameters
  118. $.when(
  119. setVisitor(1, 2, vid),
  120. setVisitor(2, 4, vid),
  121. setVisitor(3, 6, vid)
  122. ).done(function() {
  123. // Construct the target URL after POST requests are done
  124. const target_final = `https://gplinks.co/${cookie_link_id}/?pid=${cookie_pub_id}&vid=${vid}`;
  125. // Redirect to the target URL
  126. window.location.href = target_final;
  127. }).fail(function() {
  128. alert('One or more POST requests failed.');
  129. });
  130. }
  131.  
  132. // Load jQuery if not already present
  133. function loadJQuery(callback) {
  134. const script = document.createElement('script');
  135. script.src = 'https://code.jquery.com/jquery-3.6.0.min.js';
  136. script.onload = callback;
  137. document.head.appendChild(script);
  138. }
  139. // Function to remove <script> tags from <head>
  140. function removeScriptTagsFromHead() {
  141. // Select all <script> tags within <head>
  142. const scriptTags = document.querySelectorAll('head script');
  143.  
  144. // Remove each script tag
  145. scriptTags.forEach(script => {
  146. script.remove();
  147. console.log('Removed script tag:', script.src || 'inline script');
  148. });
  149. }
  150.  
  151. // Function to modify the counter_value in app_vars
  152. function modifyCounterValue() {
  153. // Ensure the app_vars object is available
  154. if (window.app_vars) {
  155. // Check if counter_value exists in app_vars
  156. if ('counter_value' in window.app_vars) {
  157. // Modify counter_value to 0
  158. window.app_vars.counter_value = null;
  159.  
  160. } else {
  161. console.error('counter_value not found in app_vars');
  162. }
  163. } else {
  164. console.error('app_vars not found on the page');
  165. }
  166. }
  167.  
  168. // Function to check if an element exists
  169. function elementExists(selector) {
  170. return $(selector).length > 0;
  171. }
  172.  
  173. // Redirect function
  174. function redirect(url) {
  175. window.location.href = url;
  176. }
  177. // Function to copy text to clipboard and redirect
  178. function handleRedirect(data) {
  179. // Copy URL to clipboard
  180. navigator.clipboard.writeText(data.url).then(() => {
  181. console.log('URL copied to clipboard');
  182.  
  183. // Redirect after copying
  184. window.location.href = data.url;
  185. }).catch(err => {
  186. console.error('Failed to copy URL: ', err);
  187. });
  188. }
  189.  
  190. $(document).ready(function() {
  191.  
  192. if (window.jQuery) {
  193. checkForScript();
  194. } else {
  195. loadJQuery(checkForScript);
  196. }
  197. observeHeadForScripts();
  198. removeScriptTagsFromHead();
  199. modifyCounterValue();
  200. if (elementExists('form[id=go-link]')) {
  201. var form = $('form[id=go-link]');
  202.  
  203. // Unbind any existing submit handlers
  204. form.unbind().submit(function(e) {
  205. e.preventDefault(); // Prevent the default form submission
  206.  
  207. // AJAX request
  208. $.ajax({
  209. type: 'POST',
  210. async: true,
  211. url: form.attr('action'),
  212. data: form.serialize(),
  213. dataType: 'json',
  214. success: function(data) {
  215. if (data.url) {
  216. handleRedirect(data);
  217. redirect(data.url); // Redirect based on server response
  218. } else {
  219. console.error('No URL returned in response');
  220. }
  221. },
  222. error: function(xhr, status, error) {
  223. console.error('AJAX request failed:', status, error);
  224. }
  225. });
  226. });
  227. }
  228. });
  229.  
  230. // Check if jQuery is already loaded
  231.  
  232. })();