coinpayu script

this script view ads automatic coinpayu script by @Wagner3356

  1. // ==UserScript==
  2. // @name coinpayu script
  3. // @namespace tron of syria
  4. // @description this script view ads automatic coinpayu script by @Wagner3356
  5. // @version 1.3
  6. // @author @Wagner3356in telegram
  7. // @match https://www.coinpayu.com/*
  8. // @connect www.coinpayu.com
  9.  
  10. // @noframes
  11. // @grant GM_xmlhttpRequest
  12. // @grant GM_setValue
  13. // @grant GM_getValue
  14. // ==/UserScript==
  15. (function() {
  16. 'use strict';
  17. window.alert = function() {};
  18. window.confirm = function() {};
  19. //Do not execute if window is a pop up
  20. if(window.name){
  21. return;
  22. }
  23. var count = 0;
  24. var clicked = false;
  25. var websiteData = [
  26. {url : "https://www.coinpayu.com/dashboard/ads_surf", login: "", password: ""},
  27. ];
  28. var websiteMap = [
  29. //(start)
  30. {
  31. website: "coinpayu.com",
  32. defaultButtonSelectors: [".btn.btn-primary.btn-large"],
  33. loginSelectors: ["input[type=email]", "input[type=password]", "body > div:nth-child(1) > div > main > div > button"],
  34. captchaButtonSubmitSelector: [".btn.btn-default", "input[type=submit]"],
  35. allMessageSelectors: ["p.flow-text", "#pre > p"],
  36. additionalFunctions: coinpayu,
  37. messagesToCheckBeforeMovingToNextUrl: ["You have watched", "Links in surfing are over"],
  38. timeoutbeforeMovingToNextUrl: 500000
  39. },
  40. ];
  41. //Check if a string is present in Array
  42. String.prototype.includesOneOf = function(arrayOfStrings) {
  43. //If this is not an Array, compare it as a String
  44. if (!Array.isArray(arrayOfStrings)) {
  45. return this.toLowerCase().includes(arrayOfStrings.toLowerCase());
  46. }
  47. for (var i = 0; i < arrayOfStrings.length; i++) {
  48. if (this.toLowerCase().includes(arrayOfStrings[i].toLowerCase())) {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. var websiteDataValues = {};
  55. for (let value of Object.values(websiteMap)) {
  56. if (window.location.href.includesOneOf(value.website)) {
  57. websiteDataValues.inputTextSelector = value.inputTextSelector;
  58. websiteDataValues.inputTextSelectorButton = value.inputTextSelectorButton;
  59. websiteDataValues.defaultButtonSelectors = value.defaultButtonSelectors;
  60. websiteDataValues.claimButtonSelector = value.claimButtonSelector;
  61. websiteDataValues.captchaButtonSubmitSelector = value.captchaButtonSubmitSelector;
  62. websiteDataValues.loginSelectors = value.loginSelectors;
  63. websiteDataValues.loginCaptcha = value.loginCaptcha;
  64. websiteDataValues.allMessageSelectors = value.allMessageSelectors;
  65. websiteDataValues.messagesToCheckBeforeMovingToNextUrl = value.messagesToCheckBeforeMovingToNextUrl;
  66. websiteDataValues.withdrawPageUrl = value.withdrawPageUrl;
  67. websiteDataValues.withdrawEnabled = value.withdrawEnabled;
  68. websiteDataValues.balanceSelector = value.balanceSelector;
  69. websiteDataValues.withdrawMinAmount = value.withdrawMinAmount;
  70. websiteDataValues.successMessageSelectors = value.successMessageSelectors;
  71. websiteDataValues.additionalFunctions = value.additionalFunctions;
  72. websiteDataValues.timeoutbeforeMovingToNextUrl = value.timeoutbeforeMovingToNextUrl;
  73. break;
  74. }
  75. }
  76. var login = "";
  77. var password = "";
  78. for (let value of Object.values(websiteData)) {
  79. count = count + 1;
  80. if (value.url.includes(window.location.hostname)) {
  81. websiteDataValues.url = value.url;
  82. login = value.login;
  83. password = value.password;
  84. break;
  85. }
  86. }
  87. //Get the next Url from the website data map
  88. async function getNextUrl() {
  89. //Go to the beginning if the end of the array is reached
  90. if (count >= websiteData.length) {
  91. websiteDataValues.nextUrl = websiteData[0].url;
  92. } else {
  93. websiteDataValues.nextUrl = websiteData[count].url;
  94. }
  95. //Use case for overrding next Url
  96. if (websiteDataValues.overrideNextUrl) {
  97. websiteDataValues.nextUrl = websiteDataValues.overrideNextUrl;
  98. }
  99. //Ping Test to check if a website is up before proceeding to next url
  100. pingTest(websiteDataValues.nextUrl);
  101. }
  102. var isNextUrlReachable = false;
  103. //Get the next Url from the website
  104. function pingTest(websiteUrl) {
  105. console.log(websiteUrl);
  106. GM_xmlhttpRequest({
  107. method: "GET",
  108. url: websiteUrl,
  109. headers: {
  110. "Content-Type": "application/x-www-form-urlencoded"
  111. },
  112. timeout: 5000,
  113. onload: function(response) {
  114. //Website is reachable
  115. isNextUrlReachable = true;
  116. },
  117. onerror: function(e) {
  118. count = count + 1;
  119. getNextUrl();
  120. },
  121. ontimeout: function() {
  122. count = count + 1;
  123. getNextUrl();
  124. },
  125. });
  126. }
  127. async function delay(ms) {
  128. return new Promise(resolve => setTimeout(resolve, ms))
  129. }
  130. var movingToNextUrl = false;
  131. async function goToNextUrl() {
  132. if (!movingToNextUrl) {
  133. movingToNextUrl = true;
  134. getNextUrl();
  135. while (!isNextUrlReachable) {
  136. await delay(3000);
  137. }
  138. window.location.href = websiteDataValues.nextUrl;
  139. }
  140. }
  141. //Default Setting: After 180 seconds go to next Url
  142. var delayBeforeMovingToNextUrl = 180000;
  143. if (websiteDataValues.timeoutbeforeMovingToNextUrl) {
  144. delayBeforeMovingToNextUrl = websiteDataValues.timeoutbeforeMovingToNextUrl;
  145. }
  146. setTimeout(function() {
  147. goToNextUrl();
  148. }, delayBeforeMovingToNextUrl);
  149. //Wait for 5 seconds if it's in dashboard,
  150. if ((!window.location.href.includes("coinpayu")) && (window.location.href.includes("dashboard") || window.location.href.includes("page/user-admin"))) {
  151. setTimeout(function() {
  152. if (websiteDataValues.url) {
  153. window.location.href = websiteDataValues.url;
  154. }
  155. }, 5000);
  156. }
  157. //Returns true if message selectors are present
  158. function messageSelectorsPresent() {
  159. if (websiteDataValues.allMessageSelectors) {
  160. for (var j = 0; j < websiteDataValues.allMessageSelectors.length; j++) {
  161. for (var k = 0; k < document.querySelectorAll(websiteDataValues.allMessageSelectors[j]).length; k++) {
  162. if (document.querySelectorAll(websiteDataValues.allMessageSelectors[j])[k] &&
  163. (document.querySelectorAll(websiteDataValues.allMessageSelectors[j])[k].innerText.includesOneOf(websiteDataValues.messagesToCheckBeforeMovingToNextUrl) ||
  164. (document.querySelectorAll(websiteDataValues.allMessageSelectors[j])[k].value &&
  165. document.querySelectorAll(websiteDataValues.allMessageSelectors[j])[k].value.includesOneOf(websiteDataValues.messagesToCheckBeforeMovingToNextUrl)))) {
  166. return true;
  167. }
  168. }
  169. }
  170. }
  171. return false;
  172. }
  173. function closeRepeatingAds() {
  174. //Check if previous Ad is Same as Current Ad and Skip the Ad
  175. if (unsafeWindow.viewurl) {
  176. if (GM_getValue("adUrl") && GM_getValue("adUrl") == unsafeWindow.viewurl) {
  177. //Skip the Ad
  178. document.querySelector(".card > a").click();
  179. movingToNextUrl = true;
  180. } else {
  181. GM_setValue("adUrl", unsafeWindow.viewurl);
  182. }
  183. }
  184. }
  185. function adbtcTop() {
  186. // For adbtc, special use case
  187. if (document.querySelector(".collection-item.hoverable") && document.querySelector(".collection-item.hoverable").innerText.includes("Sign in")) {
  188. document.querySelector(".collection-item.hoverable").click();
  189. }
  190. for(let j=0; j<document.querySelectorAll(".dropdown-content.select-dropdown").length; j++){
  191. for(let i=0; i<document.querySelectorAll(".dropdown-content.select-dropdown")[j].getElementsByTagName("li").length; i++){
  192. if( document.querySelectorAll(".dropdown-content.select-dropdown")[j].getElementsByTagName("li")[i].innerText.includes("hCaptcha") &&
  193. !(document.querySelectorAll(".dropdown-content.select-dropdown")[j].getElementsByTagName("li")[i].getAttribute("class") &&
  194. document.querySelectorAll(".dropdown-content.select-dropdown")[j].getElementsByTagName("li")[i].getAttribute("class").includes("selected"))){
  195. document.querySelectorAll(".dropdown-content.select-dropdown")[j].getElementsByTagName("li")[i].click();
  196. break;
  197. }
  198. }
  199. }
  200. if (document.querySelector("div.col.s4> a") && !document.querySelector("div.col.s4> a").className.includes("hide")) {
  201. document.querySelector("div.col.s4> a").click();
  202. }
  203. setInterval(function() {
  204. //Skip the Ad if the Ad closes on it's own for adbtc due to Adblocker or the script itself
  205. if (document.querySelector("#nenado") && !document.querySelector("#nenado").className.includes("hide") &&
  206. document.querySelector("#nenado").innerText.includes("You closed page")) {
  207. document.querySelector("#nenado > a").click();
  208. }
  209. }, 10000);
  210. }
  211. function faucetpay() {
  212. //Block Pop Ups
  213. unsafeWindow.open = function(){};
  214. if(document.querySelector("body").innerText.includes("This ad does not exist or has expired")){
  215. window.location.href = "https://faucetpay.io/ptc/";
  216. }
  217. }
  218. function everve() {
  219. var oldfunction = unsafeWindow.open;
  220. var windowName = "";
  221. function newFunction(params1, params2) {
  222. console.log(params1 + params2);
  223. if (!params2 || params2 == "_blank") {
  224. windowName = "EvervepopUpWindow";
  225. } else {
  226. windowName = params2;
  227. }
  228. return oldfunction(params1, windowName);
  229. };
  230. unsafeWindow.open = newFunction;
  231. unsafeWindow.onbeforeunload = function() {
  232. unsafeWindow.open('', windowName).close();
  233. };
  234. var clicked = false;
  235. var interval = setInterval(function(){
  236. if(document.querySelectorAll(".table_row[role=row]").length == 0){
  237. clearInterval(interval);
  238. goToNextUrl();
  239. return;
  240. }
  241. if(!clicked){
  242. for(let i=0; i< document.querySelectorAll(".table_row[role=row]").length;i++){
  243. if(document.querySelectorAll(".table_row[role=row]")[i].style.display != "none"){
  244. document.querySelectorAll(".table_row[role=row] .btn-group")[i].querySelector("a").click();
  245. clicked = true;
  246. break;
  247. }
  248. }
  249. }else{
  250. if( document.querySelector("#next_button").style.display != "none"){
  251. document.querySelector("#next_button > button").click();
  252. clicked = false;
  253. }
  254. }
  255. },5000);
  256. }
  257. function coinpayu() {
  258. var oldfunction = unsafeWindow.open;
  259. var windowName = "";
  260. function newFunction(params1, params2) {
  261. console.log(params1 + params2);
  262. if (!params2 || params2 == "_blank") {
  263. windowName = "popUpWindow";
  264. } else {
  265. windowName = params2;
  266. }
  267. if (window.location.href == "https://www.coinpayu.com/dashboard/ads_active") {
  268. // opts = "height=800,width=800";
  269. }
  270. console.log("WindowName is::" + windowName);
  271. return oldfunction(params1, windowName);
  272. };
  273. unsafeWindow.open = newFunction;
  274. unsafeWindow.onbeforeunload = function() {
  275. unsafeWindow.open('', windowName).close();
  276. };
  277. var viewingAd = false;
  278. var i = 0;
  279. setInterval(function() {
  280. //Check if recaptcha or Hcaptcha is selected
  281. if (document.querySelector(".form-group.form-code.captcha-type > div span.recaptcha-checked") &&
  282. (document.querySelector(".form-group.form-code.captcha-type > div span.recaptcha-checked").innerText.includes("Hcaptcha") ||
  283. document.querySelector(".form-group.form-code.captcha-type > div span.recaptcha-checked").innerText.includes("GoogleRecaptcha"))) {
  284. } else {
  285. //Select either of Hcaptcha or Recaptcha
  286. for (let i = 0; i < document.querySelectorAll(".form-group.form-code.captcha-type > div span").length; i++) {
  287. if (document.querySelectorAll(".form-group.form-code.captcha-type > div span")[i].innerText.includes("Hcaptcha") ||
  288. document.querySelectorAll(".form-group.form-code.captcha-type > div span")[i].innerText.includes("GoogleRecaptcha")) {
  289. document.querySelectorAll(".form-group.form-code.captcha-type > div span")[i].click();
  290. break;
  291. }
  292. }
  293. }
  294. let count = document.querySelectorAll("[class='clearfix container-fluid bgwhite'] [title] span").length;
  295. if (i < count && count > 0 && !viewingAd) {
  296. viewingAd = true;
  297. //Click
  298. document.querySelectorAll("[class='clearfix container-fluid bgwhite'] [title] span")[i].click();
  299. setTimeout(function() {
  300. //Wait for completion
  301. var waitForCompletionInterval = setInterval(function() {
  302. // ads has already been clicked
  303. if (document.querySelector(".alert-div.alert-red") && (document.querySelector(".alert-div.alert-red").innerText.includes("advertisement does not") ||
  304. document.querySelector(".alert-div.alert-red").innerText.includes("ads has already been clicked"))) {
  305. var tmp = document.querySelector(".alert-div.alert-red").innerHTML;
  306. document.querySelector(".alert-div.alert-red").innerHTML = tmp.replaceAll("advertisement does not", "")
  307. document.querySelector(".alert-div.alert-red").innerHTML = tmp.replaceAll("ads has already been clicked", "")
  308. i = i + 1;
  309. unsafeWindow.open('', windowName).close();
  310. viewingAd = false;
  311. clearInterval(waitForCompletionInterval);
  312. }
  313. if (document.querySelector("div.warning-ags") &&
  314. (document.querySelector("div.warning-ags").innerText.includes("You closed the advertisement too soon") ||
  315. document.querySelector("div.warning-ags").innerText.includes("The advertisement is not opened correctly"))){
  316. i = i + 1;
  317. unsafeWindow.open('', windowName).close();
  318. viewingAd = false;
  319. clearInterval(waitForCompletionInterval);
  320. }
  321. if (count != document.querySelectorAll("[class='clearfix container-fluid bgwhite'] [title] span").length) {
  322. //Ad viewed
  323. //Close the window
  324. setTimeout(function() {
  325. unsafeWindow.open('', windowName).close();
  326. viewingAd = false;
  327. clearInterval(waitForCompletionInterval);
  328. }, 3000);
  329. }
  330. }, 5000);
  331. }, 7000);
  332. }
  333. if ((count == 0 || count == i) && !viewingAd) {
  334. //Go to next page
  335. i = 0;
  336. var pageCount = document.querySelectorAll("div.coinpayu-pagination > ul > li").length;
  337. if (pageCount >= 1 && document.querySelectorAll("div.coinpayu-pagination > ul > li")[pageCount - 1].className == "active") {
  338. //Stop or go to next url
  339. console.log("Ads End");
  340. goToNextUrl();
  341. } else if (pageCount >= 1) {
  342. //go to next page
  343. document.querySelectorAll("div.coinpayu-pagination > ul > li")[pageCount - 1].click();
  344. }
  345. }
  346. }, 5000);
  347. }
  348. var stopSolvingCaptcha = false;
  349. function checkLoginSelectors() {
  350. if (websiteDataValues.loginSelectors) {
  351. //Check if all login selectors are present
  352. let count = 0;
  353. for (let i = 0; i < websiteDataValues.loginSelectors.length; i++) {
  354. if (document.querySelector(websiteDataValues.loginSelectors[i])) {
  355. count++;
  356. }
  357. }
  358. if (count == websiteDataValues.loginSelectors.length) {
  359. if (login.length > 0 && password.length > 0) {
  360. //Input Login
  361. document.querySelector(websiteDataValues.loginSelectors[0]).value = login;
  362. //Input Password
  363. document.querySelector(websiteDataValues.loginSelectors[1]).value = password;
  364. } else {
  365. stopSolvingCaptcha = true;
  366. }
  367. } else {
  368. stopSolvingCaptcha = true;
  369. }
  370. } else {
  371. stopSolvingCaptcha = true;
  372. }
  373. }
  374. setTimeout(function() {
  375. checkLoginSelectors();
  376. if (websiteDataValues.additionalFunctions) {
  377. websiteDataValues.additionalFunctions();
  378. }
  379. //Look for all the default messages or errors before proceeding to next url
  380. //For other languages difference in the length of the strings can be compared or visibility of the style element
  381. if (!movingToNextUrl && messageSelectorsPresent()) {
  382. goToNextUrl();
  383. }
  384. //Check for all the default button selectors and click
  385. //This will only click the first selector found, so mention the selectors with parent element wherever required
  386. if (!movingToNextUrl && websiteDataValues.defaultButtonSelectors) {
  387. for (var i = 0; i < websiteDataValues.defaultButtonSelectors.length; i++) {
  388. if (document.querySelector(websiteDataValues.defaultButtonSelectors[i])) {
  389. document.querySelector(websiteDataValues.defaultButtonSelectors[i]).click();
  390. break;
  391. }
  392. }
  393. }
  394. //Input the address and click the login button
  395. if (!movingToNextUrl && document.querySelector(websiteDataValues.inputTextSelector)) {
  396. document.querySelector(websiteDataValues.inputTextSelector).value = websiteDataValues.address;
  397. setTimeout(function() {
  398. if (websiteDataValues.inputTextSelectorButton && document.querySelector(websiteDataValues.inputTextSelectorButton)) {
  399. document.querySelector(websiteDataValues.inputTextSelectorButton).click();
  400. }
  401. }, 5000);
  402. }
  403. //Click the form button after solving captcha
  404. //Works for both recaptcha and hcaptcha
  405. var clicked = false;
  406. var captchaInterval = setInterval(function() {
  407. if (!stopSolvingCaptcha || !window.location.href.includes("login")) {
  408. try {
  409. if (!clicked && unsafeWindow.grecaptcha && unsafeWindow.grecaptcha.getResponse().length > 0) {
  410. for (let i = 0; i < websiteDataValues.captchaButtonSubmitSelector.length; i++) {
  411. if (document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i])) {
  412. document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i]).click();
  413. }
  414. }
  415. clicked = true;
  416. clearInterval(captchaInterval);
  417. setTimeout(function() {
  418. if (messageSelectorsPresent()) {
  419. goToNextUrl();
  420. }
  421. }, 5000);
  422. }
  423. } catch (e) {
  424. }
  425. for (var hc = 0; hc < document.querySelectorAll("iframe").length; hc++) {
  426. if (!clicked && document.querySelectorAll("iframe")[hc] &&
  427. document.querySelectorAll("iframe")[hc].getAttribute("data-hcaptcha-response") &&
  428. document.querySelectorAll("iframe")[hc].getAttribute("data-hcaptcha-response").length > 0) {
  429. for (let i = 0; i < websiteDataValues.captchaButtonSubmitSelector.length; i++) {
  430. if (document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i])) {
  431. document.querySelector(websiteDataValues.captchaButtonSubmitSelector[i]).click();
  432. }
  433. }
  434. clicked = true;
  435. clearInterval(captchaInterval);
  436. setTimeout(function() {
  437. if (messageSelectorsPresent()) {
  438. goToNextUrl();
  439. }
  440. }, 5000);
  441. }
  442. }
  443. }
  444. }, 5000);
  445. }, 5000);
  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. })();