PTC 1 2023

Multi WEB AutoRotasi

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

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