Shortlink Website

Multi Shortlink Auto Click

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

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