AutoClickShortlink

Multi Shortlink Auto Click

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/457316/1132976/AutoClickShortlink.js

  1. // ==UserScript==
  2. // @name AutoClickShortlink
  3. // @namespace Shortlink
  4. // @version 1.1
  5. // @description Multi Shortlink Auto Click
  6. // @author Saputra
  7. // @match https://vsl.one/*
  8. // @match https://sports4dbtc.com/*
  9. // @connect vsl.one
  10. // @connect sports4dbtc.com
  11. // @grant GM_xmlhttpRequest
  12. // @grant GM_setValue
  13. // @grant GM_getValue
  14.  
  15. // ==/UserScript==
  16. (function() {
  17.  
  18. 'use strict';
  19. window.alert = function() {};
  20. window.confirm = function() {};
  21.  
  22.  
  23. //Do not execute if window is a pop up
  24. if(window.name){
  25. return;
  26. }
  27.  
  28. var count = 0;
  29. var clicked = false;
  30.  
  31.  
  32. //Enter your login and password below, if you like to Autologin. Be careful while providing passwords,
  33. //else you may get your accounts locked
  34. var websiteData = [
  35.  
  36. {url : "https://sports4dbtc.com/shortlinks.html", login: "", password: ""},
  37. {url : "https://vsl.one", login: "", password: ""},
  38. ];
  39.  
  40. var websiteMap = [{
  41.  
  42. website: ["sports4dbtc.com"],
  43. defaultButtonSelectors: [".card-body.p-1 .btn.btn-success.btn-sm"],
  44. timeoutbeforeMovingToNextUrl: 12000
  45.  
  46. },
  47.  
  48. {
  49.  
  50. website: ["vsl.one"],
  51. defaultButtonSelectors: [".card-body.p-1 .btn.btn-success.btn-sm"],
  52. timeoutbeforeMovingToNextUrl: 15000
  53.  
  54. },
  55.  
  56. ];
  57.  
  58.  
  59. //Check if a string is present in Array
  60. String.prototype.includesOneOf = function(arrayOfStrings) {
  61.  
  62. //If this is not an Array, compare it as a String
  63. if (!Array.isArray(arrayOfStrings)) {
  64. return this.toLowerCase().includes(arrayOfStrings.toLowerCase());
  65. }
  66.  
  67. for (var i = 0; i < arrayOfStrings.length; i++) {
  68. if (this.toLowerCase().includes(arrayOfStrings[i].toLowerCase())) {
  69. return true;
  70. }
  71. }
  72. return false;
  73. }
  74.  
  75.  
  76.  
  77. var websiteDataValues = {};
  78.  
  79. //Get selector details from the websiteMap
  80. for (let value of Object.values(websiteMap)) {
  81. if (window.location.href.includesOneOf(value.website)) {
  82. websiteDataValues.inputTextSelector = value.inputTextSelector;
  83. websiteDataValues.inputTextSelectorButton = value.inputTextSelectorButton;
  84. websiteDataValues.defaultButtonSelectors = value.defaultButtonSelectors;
  85. websiteDataValues.claimButtonSelector = value.claimButtonSelector;
  86. websiteDataValues.captchaButtonSubmitSelector = value.captchaButtonSubmitSelector;
  87. websiteDataValues.loginSelectors = value.loginSelectors;
  88. websiteDataValues.loginCaptcha = value.loginCaptcha;
  89. websiteDataValues.allMessageSelectors = value.allMessageSelectors;
  90. websiteDataValues.messagesToCheckBeforeMovingToNextUrl = value.messagesToCheckBeforeMovingToNextUrl;
  91. websiteDataValues.withdrawPageUrl = value.withdrawPageUrl;
  92. websiteDataValues.withdrawEnabled = value.withdrawEnabled;
  93. websiteDataValues.balanceSelector = value.balanceSelector;
  94. websiteDataValues.withdrawMinAmount = value.withdrawMinAmount;
  95. websiteDataValues.successMessageSelectors = value.successMessageSelectors;
  96. websiteDataValues.additionalFunctions = value.additionalFunctions;
  97. websiteDataValues.timeoutbeforeMovingToNextUrl = value.timeoutbeforeMovingToNextUrl;
  98. break;
  99. }
  100. }
  101.  
  102.  
  103. var login = "";
  104. var password = "";
  105.  
  106. for (let value of Object.values(websiteData)) {
  107. count = count + 1;
  108. if (value.url.includes(window.location.hostname)) {
  109. websiteDataValues.url = value.url;
  110. login = value.login;
  111. password = value.password;
  112. break;
  113. }
  114. }
  115.  
  116.  
  117. //Get the next Url from the website data map
  118. async function getNextUrl() {
  119.  
  120. //Go to the beginning if the end of the array is reached
  121. if (count >= websiteData.length) {
  122. websiteDataValues.nextUrl = websiteData[0].url;
  123. } else {
  124. websiteDataValues.nextUrl = websiteData[count].url;
  125. }
  126.  
  127. //Use case for overrding next Url
  128. if (websiteDataValues.overrideNextUrl) {
  129. websiteDataValues.nextUrl = websiteDataValues.overrideNextUrl;
  130. }
  131.  
  132. //Ping Test to check if a website is up before proceeding to next url
  133. pingTest(websiteDataValues.nextUrl);
  134. }
  135.  
  136. var isNextUrlReachable = false;
  137. //Get the next Url from the website
  138. function pingTest(websiteUrl) {
  139. console.log(websiteUrl);
  140. GM_xmlhttpRequest({
  141. method: "GET",
  142. url: websiteUrl,
  143. headers: {
  144. "Content-Type": "application/x-www-form-urlencoded"
  145. },
  146. timeout: 5000,
  147. onload: function(response) {
  148. //Website is reachable
  149. isNextUrlReachable = true;
  150. },
  151. onerror: function(e) {
  152. count = count + 1;
  153. getNextUrl();
  154. },
  155. ontimeout: function() {
  156. count = count + 1;
  157. getNextUrl();
  158. },
  159. });
  160.  
  161. }
  162.  
  163.  
  164. async function delay(ms) {
  165. return new Promise(resolve => setTimeout(resolve, ms))
  166. }
  167.  
  168.  
  169. var movingToNextUrl = false;
  170. async function goToNextUrl() {
  171. if (!movingToNextUrl) {
  172. movingToNextUrl = true;
  173. getNextUrl();
  174. while (!isNextUrlReachable) {
  175. await delay(3000);
  176. }
  177. window.location.href = websiteDataValues.nextUrl;
  178. }
  179. }
  180.  
  181.  
  182. //Default Setting: After 120 seconds go to next Url
  183. var delayBeforeMovingToNextUrl = 120000;
  184. if (websiteDataValues.timeoutbeforeMovingToNextUrl) {
  185. delayBeforeMovingToNextUrl = websiteDataValues.timeoutbeforeMovingToNextUrl;
  186. }
  187.  
  188. setTimeout(function() {
  189. goToNextUrl();
  190. }, delayBeforeMovingToNextUrl);
  191.  
  192.  
  193.  
  194. //Returns true if message selectors are present
  195. function messageSelectorsPresent() {
  196. if (websiteDataValues.allMessageSelectors) {
  197. for (var j = 0; j < websiteDataValues.allMessageSelectors.length; j++) {
  198. for (var k = 0; k < document.querySelectorAll(websiteDataValues.allMessageSelectors[j]).length; k++) {
  199. if (document.querySelectorAll(websiteDataValues.allMessageSelectors[j])[k] &&
  200. (document.querySelectorAll(websiteDataValues.allMessageSelectors[j])[k].innerText.includesOneOf(websiteDataValues.messagesToCheckBeforeMovingToNextUrl) ||
  201. (document.querySelectorAll(websiteDataValues.allMessageSelectors[j])[k].value &&
  202. document.querySelectorAll(websiteDataValues.allMessageSelectors[j])[k].value.includesOneOf(websiteDataValues.messagesToCheckBeforeMovingToNextUrl)))) {
  203. return true;
  204. }
  205. }
  206. }
  207. }
  208. return false;
  209. }
  210.  
  211. function closeRepeatingAds() {
  212.  
  213. //Check if previous Ad is Same as Current Ad and Skip the Ad
  214. if (unsafeWindow.viewurl) {
  215. if (GM_getValue("adUrl") && GM_getValue("adUrl") == unsafeWindow.viewurl) {
  216. //Skip the Ad
  217. document.querySelector(".card > a").click();
  218. movingToNextUrl = true;
  219. } else {
  220. GM_setValue("adUrl", unsafeWindow.viewurl);
  221. }
  222.  
  223. }
  224.  
  225. }
  226.  
  227.  
  228.  
  229. function mad() {
  230.  
  231. //Block Pop Ups
  232. unsafeWindow.open = function(){};
  233.  
  234. if(document.querySelector("body").innerText.includes("This ad does not exist or has expired")){
  235. window.location.href = "https://mad.fun/link/";
  236. }
  237.  
  238. }
  239.  
  240.  
  241. var stopSolvingCaptcha = false;
  242.  
  243. function checkLoginSelectors() {
  244.  
  245. if (websiteDataValues.loginSelectors) {
  246. //Check if all login selectors are present
  247. let count = 0;
  248. for (let i = 0; i < websiteDataValues.loginSelectors.length; i++) {
  249. if (document.querySelector(websiteDataValues.loginSelectors[i])) {
  250. count++;
  251. }
  252.  
  253. }
  254.  
  255. if (count == websiteDataValues.loginSelectors.length) {
  256.  
  257. if (login.length > 0 && password.length > 0) {
  258. //Input Login
  259. document.querySelector(websiteDataValues.loginSelectors[0]).value = login;
  260.  
  261. //Input Password
  262. document.querySelector(websiteDataValues.loginSelectors[1]).value = password;
  263. } else {
  264. stopSolvingCaptcha = true;
  265. }
  266.  
  267. } else {
  268. stopSolvingCaptcha = true;
  269. }
  270.  
  271. } else {
  272. stopSolvingCaptcha = true;
  273. }
  274.  
  275. }
  276.  
  277.  
  278. setTimeout(function() {
  279.  
  280. checkLoginSelectors();
  281.  
  282. if (websiteDataValues.additionalFunctions) {
  283. websiteDataValues.additionalFunctions();
  284. }
  285.  
  286. //Look for all the default messages or errors before proceeding to next url
  287. //For other languages difference in the length of the strings can be compared or visibility of the style element
  288. if (!movingToNextUrl && messageSelectorsPresent()) {
  289. goToNextUrl();
  290. }
  291.  
  292.  
  293. //Check for all the default button selectors and click
  294. //This will only click the first selector found, so mention the selectors with parent element wherever required
  295. if (!movingToNextUrl && websiteDataValues.defaultButtonSelectors) {
  296. for (var i = 0; i < websiteDataValues.defaultButtonSelectors.length; i++) {
  297. if (document.querySelector(websiteDataValues.defaultButtonSelectors[i])) {
  298. document.querySelector(websiteDataValues.defaultButtonSelectors[i]).click();
  299. break;
  300. }
  301. }
  302. }
  303.  
  304. //Input the address and click the login button
  305. if (!movingToNextUrl && document.querySelector(websiteDataValues.inputTextSelector)) {
  306. document.querySelector(websiteDataValues.inputTextSelector).value = websiteDataValues.address;
  307. setTimeout(function() {
  308. if (websiteDataValues.inputTextSelectorButton && document.querySelector(websiteDataValues.inputTextSelectorButton)) {
  309. document.querySelector(websiteDataValues.inputTextSelectorButton).click();
  310. }
  311.  
  312. }, 5000);
  313. }
  314.  
  315.  
  316. //Click the form button after solving captcha
  317. //Works for both recaptcha and hcaptcha
  318. var clicked = false;
  319. var captchaInterval = setInterval(function() {
  320. if (!stopSolvingCaptcha || !window.location.href.includes("login")) {
  321. try {
  322. if (!clicked && unsafeWindow.grecaptcha && unsafeWindow.grecaptcha.getResponse().length > 0) {
  323. for (let i = 0; i < websiteDataValues.captchaButtonSubmitSelector.length; i++) {
  324. if (document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i])) {
  325. document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i]).click();
  326. }
  327. }
  328. clicked = true;
  329.  
  330. clearInterval(captchaInterval);
  331. setTimeout(function() {
  332. if (messageSelectorsPresent()) {
  333. goToNextUrl();
  334. }
  335. }, 5000);
  336. }
  337. } catch (e) {
  338.  
  339. }
  340.  
  341. for (var hc = 0; hc < document.querySelectorAll("iframe").length; hc++) {
  342. if (!clicked && document.querySelectorAll("iframe")[hc] &&
  343. document.querySelectorAll("iframe")[hc].getAttribute("data-hcaptcha-response") &&
  344. document.querySelectorAll("iframe")[hc].getAttribute("data-hcaptcha-response").length > 0) {
  345. for (let i = 0; i < websiteDataValues.captchaButtonSubmitSelector.length; i++) {
  346. if (document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i])) {
  347. document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i]).click();
  348. }
  349. }
  350. clicked = true;
  351. clearInterval(captchaInterval);
  352. setTimeout(function() {
  353. if (messageSelectorsPresent()) {
  354. goToNextUrl();
  355. }
  356. }, 5000);
  357. }
  358. }
  359. }
  360.  
  361. }, 5000);
  362.  
  363.  
  364. }, 5000);
  365.  
  366.  
  367. window.onbeforeunload = function() {
  368. if (unsafeWindow.myWindow) {
  369. unsafeWindow.myWindow.close();
  370. }
  371. if (unsafeWindow.coinwin) {
  372. var tmp = unsafeWindow.coinwin;
  373. unsafeWindow.coinwin = {};
  374. tmp.close();
  375. }
  376.  
  377. };
  378.  
  379. })();