PTC VieFaucet

Multi WEB AutoRotasi

目前为 2022-12-30 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/457260/1133329/PTC%20VieFaucet.js

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