PTC 4 2023

Multi WEB AutoRotasi

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

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