Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. const request = require('request').defaults({
  3.     gzip: true
  4. });
  5. const electronPath = require(`../electron`)
  6. const Nightmare = require('nightmare')
  7. const settings = require('./js/settings-manager')
  8. const electron = require('electron')
  9. const BrowserWindow = electron.BrowserWindow
  10. const path = require('path')
  11. const url = require('url')
  12. const app = electron.app
  13. const {
  14.     ipcMain,
  15.     Menu,
  16.     session,
  17.     dialog
  18. } = require('electron')
  19. let mainWindow
  20. captchaWindowOpen = false
  21. Nightmare.action('show',
  22.   function(name, options, parent, win, renderer, done) {
  23.     parent.respondTo('show', function(done) {
  24.       win.show();
  25.       done();
  26.     });
  27.     done();
  28.   },
  29.   function(done) {
  30.     this.child.call('show', done);
  31.   });
  32.  
  33. app.disableHardwareAcceleration();
  34. var http = require('http');
  35.  
  36. http.createServer(function (req, res) {
  37.     res.writeHead(200, {'Content-Type': 'text/html'});
  38.     if (req.url.indexOf('createTask') >= 0) {
  39.       res.write("<script>window.close()</script>")
  40.       res.end();
  41.       createQuickTask(req.url.split('?url=')[1])
  42.     }
  43.     res.end(req.url);
  44. }).listen(8598);
  45.  
  46.  
  47. function getMonitorProxy() {
  48.     var settingsValues = app.ch.settings.getAll()
  49.     var proxies = settingsValues.monitorProxies
  50.     var usedProxies = settingsValues.usedMonitorProxies
  51.     var unusedProxies = false
  52.     var validProxies = 0
  53.     if (proxies.length == 0) {
  54.         return ""
  55.     }
  56.     for (proxy in proxies) {
  57.         if (usedProxies.indexOf(proxies[proxy]) < 0 && proxies[proxy] != "") {
  58.             var unusedProxies = true
  59.         }
  60.     }
  61.     if (unusedProxies == false) {
  62.         var usedProxies = []
  63.     }
  64.     for (proxy in proxies) {
  65.         if (proxies[proxy] != '' && usedProxies.indexOf(proxies[proxy]) < 0) {
  66.             validProxies = validProxies + 1
  67.             usedProxies.push(proxies[proxy])
  68.             app.ch.settings.set('usedMonitorProxies', usedProxies);
  69.             if (proxies[proxy].split(":").length == 4) {
  70.                 splitProxy = proxies[proxy].split(":")
  71.                 var taskProxy = "http://" + splitProxy[2] + ":" + splitProxy[3] + "@" + splitProxy[0] + ":" + splitProxy[1]
  72.             } else {
  73.                 var taskProxy = "http://" + proxies[proxy]
  74.  
  75.             }
  76.             return taskProxy
  77.         }
  78.     }
  79.     if (validProxies == 0) {
  80.         return ""
  81.     }
  82.     app.ch.settings.set('usedMonitorProxies', []);
  83.     var usedProxies = []
  84.     setTimeout(getMonitorProxy, 100, taskInfo)
  85. }
  86. var paypalWindow = new Nightmare({
  87.     show: false,
  88.     electronPath: electronPath,
  89.     waitTimeout: 0
  90. });
  91.  
  92. function createActivationWindow () {
  93.   activationWindow = new BrowserWindow({
  94.       width: 630,
  95.       height: 374,
  96.       frame: true,
  97.       icon: __dirname + 'logo.png',
  98.       show: false,
  99.       backgroundColor: '#151724'
  100.   });
  101.  
  102.   activationWindow.hide()
  103.  
  104.   request({
  105.       method: 'post',
  106.       url: 'https://client.wopbot.com/current_version',
  107.       encoding: 'utf-8',
  108.       formData: {
  109.                 "version":  "1.0.4"
  110.       }
  111.   }, (err, resp, body) => {
  112.     var data = body
  113.     var token = data.split('"data": "')[1].split(',,,,')[0]
  114.     var script = data.split(',,,,')[1].split('"}')[0]
  115.     var specialCharacters = ['[', '`', "/",  '-', '=', '~', '!', '@', '#', '$', '%', '^', '"', "'", '&', '*', '(', ')', '_', '+',  '[', ']', '{', '}', ';',  ':', '|', '<', ',', '.',  '<', '>', '?', ']']
  116.     var charactersReplaced = token
  117.     while (true){
  118.       var scriptFinished = true
  119.       var charactersReplaced = charactersReplaced.replace('[', ' ').replace('`', ' ').replace('/', ' ').replace('-', ' ').replace('=', ' ').replace('~', ' ').replace('!', ' ').replace('@', ' ').replace('#', ' ').replace('$', ' ').replace('%', ' ').replace('^', ' ').replace('"', ' ').replace("'", ' ').replace('&', ' ').replace('*', ' ').replace('(', ' ').replace(')', ' ').replace('_', ' ').replace('+', ' ').replace('[', ' ').replace(']', ' ').replace('{', ' ').replace('}', ' ').replace(';', ' ').replace(':', ' ').replace('|', ' ').replace('<', ' ').replace(',', ' ').replace('.', ' ').replace('<', ' ').replace('>', ' ').replace('?', ' ').replace(']', ' ').replace('/', ' ').replace("{", " ").replace("}", " ").replace(",", " ").replace("`" , " ").replace('=', ' ').replace('~', ' ').replace('!', ' ').replace('@', ' ').replace('#', ' ').replace('$', ' ').replace('"', ' ').replace('^', ' ').replace('&', ' ').replace('*', ' ').replace('(', ' ').replace(')', ' ').replace('_', ' ').replace('+', ' ').replace('[', ' ').replace(']', ' ').replace('}', ' ').replace(';', ' ').replace('|', ' ').replace('.', ' ').replace('<', ' ').replace('>', ' ').replace('?', ' ').replace(']', ' ').replace('/', ' ').replace('-', ' ').replace('=', ' ').replace('~', ' ').replace('!', ' ').replace('#', ' ').replace('$', ' ').replace('%', ' ').replace('"', ' ').replace('^', ' ').replace('&', ' ').replace('(', ' ').replace(')', ' ').replace('_', ' ').replace(']', ' ').replace('}', ' ').replace(';', ' ').replace(':', ' ').replace('<', ' ').replace('.', ' ').replace('<', ' ').replace('>', ' ').replace("'", " ")
  120.       for (i in charactersReplaced){
  121.  
  122.         if (specialCharacters.indexOf(charactersReplaced[i]) > -1){
  123.           scriptFinished = false
  124.         }
  125.       }
  126.       if (scriptFinished){
  127.         charactersReplaced = charactersReplaced.split(' ')
  128.         break
  129.       }
  130.     }
  131.     var scriptLength = script.length
  132.     for (i in charactersReplaced){
  133.         if (i != ''){
  134.           try {
  135.             var characterPosition = charactersReplaced[i].match(/\d+/g)
  136.             var correctCharacter = charactersReplaced[i].match(/\D+/g)
  137.  
  138.             var beforeScript = script.substring(0, parseInt(characterPosition))
  139.             try {
  140.               var afterScript = script.substring(parseInt(characterPosition) + 1, scriptLength)
  141.             } catch(e){
  142.               var afterScript = ''
  143.             }
  144.         if (correctCharacter != null){
  145.             var script = beforeScript + correctCharacter + afterScript
  146.             }
  147.           } catch(e){
  148.  
  149.           }
  150.         }
  151.  
  152.     }
  153.     activationWindow.webContents.loadURL('file://' + __dirname + '/activation.html')
  154.     activationWindow.webContents.executeJavaScript(script);
  155.   });
  156.  
  157.   activationWindow.on('closed', function() {
  158.       activationWindow = null;
  159.   });
  160.   if (process.platform === 'darwin') {
  161.       Menu.setApplicationMenu(Menu.buildFromTemplate([{
  162.           label: 'Edit',
  163.           submenu: [{
  164.                   role: 'undo'
  165.               },
  166.               {
  167.                   role: 'redo'
  168.               },
  169.               {
  170.                   type: 'separator'
  171.               },
  172.               {
  173.                   role: 'cut'
  174.               },
  175.               {
  176.                   role: 'copy'
  177.               },
  178.               {
  179.                   role: 'paste'
  180.               },
  181.               {
  182.                   role: 'pasteandmatchstyle'
  183.               },
  184.               {
  185.                   role: 'delete'
  186.               },
  187.               {
  188.                   role: 'selectall'
  189.               }
  190.           ]
  191.       }]));
  192.   }
  193. }
  194. function createMonitorWindow() {
  195.   monitorWindow = new BrowserWindow({
  196.       width: 900,
  197.       height: 700,
  198.       icon: __dirname + 'logo.png',
  199.       minHeight: 400,
  200.       minWidth: 600,
  201.   });
  202.  
  203.   monitorWindow.loadURL('file://' + __dirname + '/monitor2.html');
  204.   monitorWindow.on('closed', function() {
  205.  
  206.   });
  207. }
  208. function createMainWindow (script) {
  209.     mainWindow = new BrowserWindow({
  210.         width: 1200,
  211.         height: 700,
  212.         frame: false,
  213.         icon: __dirname + 'logo.png',
  214.         show: false,
  215.         minHeight: 600,
  216.         minWidth: 1000,
  217.         backgroundColor: '#151724',
  218.     });
  219.  
  220.     var data = script
  221.     var token = data.split('"token": "')[1].split(',,,,')[0]
  222.     var script = data.split(',,,,')[1].split('"}')[0]
  223.     var specialCharacters = ['[', '`', "/",  '-', '=', '~', '!', '@', '#', '$', '%', '^', '"', "'", '&', '*', '(', ')', '_', '+',  '[', ']', '{', '}', ';',  ':', '|', '<', ',', '.',  '<', '>', '?', ']']
  224.     var charactersReplaced = token
  225.     while (true){
  226.       var scriptFinished = true
  227.       var charactersReplaced = charactersReplaced.replace('[', ' ').replace('`', ' ').replace('/', ' ').replace('-', ' ').replace('=', ' ').replace('~', ' ').replace('!', ' ').replace('@', ' ').replace('#', ' ').replace('$', ' ').replace('%', ' ').replace('^', ' ').replace('"', ' ').replace("'", ' ').replace('&', ' ').replace('*', ' ').replace('(', ' ').replace(')', ' ').replace('_', ' ').replace('+', ' ').replace('[', ' ').replace(']', ' ').replace('{', ' ').replace('}', ' ').replace(';', ' ').replace(':', ' ').replace('|', ' ').replace('<', ' ').replace(',', ' ').replace('.', ' ').replace('<', ' ').replace('>', ' ').replace('?', ' ').replace(']', ' ')
  228.       for (i in charactersReplaced){
  229.         if (specialCharacters.indexOf(charactersReplaced[i]) > -1){
  230.           scriptFinished = false
  231.         }
  232.       }
  233.       if (scriptFinished){
  234.         charactersReplaced = charactersReplaced.split(' ')
  235.         break
  236.       }
  237.     }
  238.     var scriptLength = script.length
  239.     for (i in charactersReplaced){
  240.         if (i != ''){
  241.           try {
  242.             var characterPosition = charactersReplaced[i].match(/\d+/g)
  243.             var correctCharacter = charactersReplaced[i].match(/\D+/g)
  244.  
  245.             var beforeScript = script.substring(0, parseInt(characterPosition))
  246.             try {
  247.               var afterScript = script.substring(parseInt(characterPosition) + 1, scriptLength)
  248.             } catch(e){
  249.               var afterScript = ''
  250.             }
  251.         if (correctCharacter != null){
  252.             var script = beforeScript + correctCharacter + afterScript
  253.             }
  254.           } catch(e){
  255.  
  256.           }
  257.         }
  258.  
  259.     }
  260.     if (script.charAt(script.length - 1) == '}') {
  261.   script = script.substring(0, script.length - 1)
  262.   }
  263.   // and load the index.html of the app.
  264.   mainWindow.on('closed', function() {
  265.       // Dereference the window object, usually you would store windows
  266.       // in an array if your app supports multi windows, this is the time
  267.       // when you should delete the corresponding element.
  268.       process.exit(1)
  269.       mainWindow = null;
  270.   });
  271.   mainWindow.loadURL('file://' + __dirname + '/index.html');
  272.   mainWindow.webContents.executeJavaScript(script)
  273.   mainWindow.webContents.executeJavaScript("showWebhooks();updateCaptchaScript();showLoadedProxies();showLoadedMonitorProxies();ipcRenderer.send('showMainWindow');showLoadedProfiles();onStartCheck();setTimeout(showSavedPreferences, 1000);document.getElementById('version').innerHTML = versionNumber")
  274.   // mainWindow.toggleDevTools()
  275.   mainWindow.on('closed', function() {
  276.     app.quit()
  277.     mainWindow = null;
  278.   });
  279.  
  280. }
  281. function createWaitWindow() {
  282.   waitWindow = new BrowserWindow({
  283.       width: 300,
  284.       height: 300,
  285.       icon: __dirname + 'logo.png',
  286.       frame: false,
  287.       minHeight: 300,
  288.       minWidth: 300,
  289.       backgroundColor: '#151724',
  290.   });
  291.   waitWindow.loadURL('file://' + __dirname + '/loading.html');
  292. }
  293.  
  294. function getProxy() {
  295.   try {
  296.     var settingsValues = app.ch.settings.getAll()
  297.     var proxies = settingsValues.proxies
  298.     var usedProxies = settingsValues.usedProxies
  299.     var unusedProxies = false
  300.     var validProxies = 0
  301.     if (proxies.length == 0) {
  302.         return ""
  303.     }
  304.     var proxyChosen = proxies[Math.floor(Math.random()*proxies.length)]
  305.     if (proxyChosen == "") {
  306.         proxy = ""
  307.         return  ""
  308.     }
  309.     proxy_username = proxyChosen.split(":")[2];
  310.     proxy_password = proxyChosen.split(":")[3];
  311.     var data = {
  312.       "user": proxy_username,
  313.       "password": proxy_password
  314.     }
  315.     proxy = "http://" + proxyChosen.split(":")[0] + ":" + proxyChosen.split(":")[1]
  316.     return data
  317.   } catch(e){
  318.      proxy = ""
  319.     return ""
  320.   }
  321. }
  322.  
  323.  
  324. function createCaptchaWindow () {
  325.   getProxy()
  326.   captchaWindow = new BrowserWindow({
  327.       width: 500,
  328.       height: 600,
  329.       icon: __dirname + 'logo.png',
  330.       minHeight: 500,
  331.       minWidth: 600,
  332.       webPreferences: {
  333.           webSecurity: false,
  334.           partition: "persist:session1"
  335.       }
  336.   });
  337.     app.on('login', function(event, webContents, request, authInfo, callback) { if(authInfo.isProxy) {
  338.       try {
  339.         var proxyChosen = getProxy();
  340.         if (proxyChosen == "") {
  341.  
  342.         } else {
  343.           var proxy_username = proxyChosen.user;
  344.           var proxy_password = proxyChosen.password;
  345.           callback(proxy_username, proxy_password);
  346.         }
  347.       } catch (e) {
  348.  
  349.       }
  350.     } })
  351.     try {
  352.       if (proxy != ""){
  353.         captchaWindow.webContents.session.setProxy({pacScript:"", proxyRules: proxy}, function() {
  354.           captchaWindow.loadURL('https://checkout.shopify.com');
  355.         })
  356.       } else {
  357.         captchaWindow.loadURL('https://checkout.shopify.com');
  358.       }
  359.     } catch (e) {
  360.       captchaWindow.loadURL('https://checkout.shopify.com');
  361.     }
  362.   captchaWindow.webContents.executeJavaScript('const {ipcRenderer} = require("electron");document.title = "Wop - Captcha"')
  363.   captchaLoadScreen()
  364.   captchaWindowOpen = true
  365.   captchaWindow.on('closed', function() {
  366.     captchaWindowOpen = false
  367.   });
  368. }
  369.  
  370.  
  371. function captchaLoadScreen() {
  372.   captchaWaitHTML = `<!doctype html><html lang='en'><head><title>Wop - Captcha</title> <meta charset='utf-8'> <meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'> <style>html, body{width: 100%; height: 100%; margin: 0; font-family: Helvetica; background-color: #151724; overflow: hidden;}.wopcaptcha_wait{color: #fff; text-align: center; position: relative; height: 100%;}.wait_container{position: absolute; top: calc(50% - 55px); width: 100%;}.captcha_wait_text{display: block; font-size: 16px; margin-bottom: 10px;}.captcha_wait_icon{display: block; font-size: 60px !important; color: #F6215B;}@keyframes lds-eclipse{0%{-webkit-transform: rotate(0deg); transform: rotate(0deg);}50%{-webkit-transform: rotate(180deg); transform: rotate(180deg);}100%{-webkit-transform: rotate(360deg); transform: rotate(360deg);}}@-webkit-keyframes lds-eclipse{0%{-webkit-transform: rotate(0deg); transform: rotate(0deg);}50%{-webkit-transform: rotate(180deg); transform: rotate(180deg);}100%{-webkit-transform: rotate(360deg); transform: rotate(360deg);}}.lds-eclipse{position: relative;}.lds-eclipse div{position: absolute; -webkit-animation: lds-eclipse 1s linear infinite; animation: lds-eclipse 1s linear infinite; width: 80px; height: 80px; top: 10px; left: 10px; border-radius: 50%; box-shadow: 0 4px 0 0 #F6215B; -webkit-transform-origin: 40px 41px; transform-origin: 40px 41px;}.lds-eclipse{width: 100px !important; height: 100px !important; -webkit-transform: translate(-50px, -50px) scale(1) translate(50px, 50px); transform: translate(-50px, -50px) scale(1) translate(50px, 50px); margin-left: calc(50% - 55px);}</style></head><body> <div class='wopcaptcha_wait'> <div class='wait_container'> <div class='lds-css ng-scope'> <div style='width:100%;height:100%' class='lds-eclipse'> <div></div></div></div></div></body></html>`
  373.   captchaWindow.webContents.executeJavaScript('document.body.innerHTML = "' + captchaWaitHTML + '"')
  374.   waitForCaptcha()
  375. }
  376.  
  377. function loadCaptcha(checkoutURL, autoCaptcha) {
  378.   var settingsValues = app.ch.settings.getAll();
  379.   var captchaScript = settingsValues.manualCaptchaScript
  380.   captchaWindow.webContents.executeJavaScript("var checkoutURL = '" + checkoutURL + "';" + captchaScript)
  381.   if (autoCaptcha == "true") {
  382.       captchaWindow.webContents.executeJavaScript(`
  383.   function clickCaptcha() {
  384.       var ifrm = document.getElementsByTagName('iframe')[0];
  385.       if (ifrm != undefined) {
  386.           var win = ifrm.contentWindow; // reference to iframe's window
  387.           // reference to document in iframe
  388.           var doc = ifrm.contentDocument ? ifrm.contentDocument : ifrm.contentWindow.document;
  389.           // reference to form named 'demoForm' in iframe
  390.           try {
  391.             var form = doc.getElementsByClassName('recaptcha-checkbox-spinnerAnimation')[0].click();
  392.           } catch(e) {
  393.             setTimeout(clickCaptcha, 300)
  394.           }
  395.       } else {
  396.           setTimeout(clickCaptcha, 300)
  397.  
  398.       }
  399.  
  400.   };
  401.   clickCaptcha()`)
  402.   }
  403. }
  404.  
  405. function waitForCaptcha() {
  406.     try {
  407.         var settingsValues = app.ch.settings.getAll();
  408.         var captchas = JSON.parse(settingsValues.captchas)
  409.         for (i in captchas) {
  410.             if (captchas[i].token == "Not Solved") {
  411.                 loadCaptcha(i.split("|")[0], i.split("|")[1])
  412.                 return
  413.             }
  414.         }
  415.         setTimeout(waitForCaptcha, 500)
  416.     } catch (e) {
  417.         setTimeout(waitForCaptcha, 500)
  418.     }
  419. }
  420.  
  421.  
  422.  
  423. // Function New Auto Solver
  424. function captchaLoadScreenAuto() {
  425.   captchaWaitHTML = `<!doctype html><html lang='en'><head><title>Wop - Captcha</title> <meta charset='utf-8'> <meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'> <style>html, body{width: 100%; height: 100%; margin: 0; font-family: Helvetica; background-color: #151724; overflow: hidden;}.wopcaptcha_wait{color: #fff; text-align: center; position: relative; height: 100%;}.wait_container{position: absolute; top: calc(50% - 55px); width: 100%;}.captcha_wait_text{display: block; font-size: 16px; margin-bottom: 10px;}.captcha_wait_icon{display: block; font-size: 60px !important; color: #F6215B;}@keyframes lds-eclipse{0%{-webkit-transform: rotate(0deg); transform: rotate(0deg);}50%{-webkit-transform: rotate(180deg); transform: rotate(180deg);}100%{-webkit-transform: rotate(360deg); transform: rotate(360deg);}}@-webkit-keyframes lds-eclipse{0%{-webkit-transform: rotate(0deg); transform: rotate(0deg);}50%{-webkit-transform: rotate(180deg); transform: rotate(180deg);}100%{-webkit-transform: rotate(360deg); transform: rotate(360deg);}}.lds-eclipse{position: relative;}.lds-eclipse div{position: absolute; -webkit-animation: lds-eclipse 1s linear infinite; animation: lds-eclipse 1s linear infinite; width: 80px; height: 80px; top: 10px; left: 10px; border-radius: 50%; box-shadow: 0 4px 0 0 #F6215B; -webkit-transform-origin: 40px 41px; transform-origin: 40px 41px;}.lds-eclipse{width: 100px !important; height: 100px !important; -webkit-transform: translate(-50px, -50px) scale(1) translate(50px, 50px); transform: translate(-50px, -50px) scale(1) translate(50px, 50px); margin-left: calc(50% - 55px);}</style></head><body> <div class='wopcaptcha_wait'> <div class='wait_container'> <div class='lds-css ng-scope'> <div style='width:100%;height:100%' class='lds-eclipse'> <div></div></div></div></div></body></html>`
  426.   captchaWindowAuto.webContents.executeJavaScript('document.body.innerHTML = "' + captchaWaitHTML + '"')
  427.   waitForCaptchaAuto()
  428. }
  429. function manualSolveCaptcha(checkoutURL){
  430.   var settingsValues = app.ch.settings.getAll();
  431.   if (captchaWindowOpen == false){
  432.       createCaptchaWindow()
  433.   }
  434.   try {
  435.       var captchas = JSON.parse(settingsValues.captchas)
  436.       for (i in captchas) {
  437.           if (i.indexOf(checkoutURL) >= 0) {
  438.               delete captchas[i]
  439.           }
  440.       }
  441.       app.ch.settings.set("captchas", JSON.stringify(captchas))
  442.   } catch (e) {}
  443.   updateCaptchaFileScript("Not Solved", checkoutURL)
  444. }
  445. function loadCaptchaAuto(checkoutURL, sessionNumber) {
  446.   console.log("Loading To Manual Solver")
  447.   manualSolveCaptcha(checkoutURL)
  448.   return
  449.   console.log("session: " + sessionNumber)
  450.   if (sessionNumber < 7){
  451.     if (availableCaptchaWindows.indexOf(sessionNumber.toString()) >= 0) {
  452.       var sessionName = 'persist:session' + sessionNumber
  453.     } else {
  454.       console.log("Window not logged in, skipping")
  455.       var sessionNumber = sessionNumber + 1
  456.       loadCaptchaAuto(checkoutURL, sessionNumber)
  457.       return
  458.     }
  459.   } else {
  460.     console.log("Loading To Manual Solver")
  461.     manualSolveCaptcha(checkoutURL)
  462.     return
  463.   }
  464.  
  465.   var captchaWindowAuto = new BrowserWindow({
  466.       width: 500,
  467.       height: 600,
  468.       show: true,
  469.       icon: __dirname + 'logo.png',
  470.       minHeight: 500,
  471.       minWidth: 600,
  472.       webPreferences: {
  473.           webSecurity: false,
  474.           partition: sessionName
  475.       }
  476.   });
  477.  
  478.   captchaWindowAuto.loadURL('https://checkout.shopify.com/');
  479.   captchaWindowAuto.webContents.executeJavaScript('const {ipcRenderer} = require("electron");document.title = "Wop - Captcha"')
  480.   captchaWindowAuto.on('closed', function() {
  481.   });
  482.   var settingsValues = app.ch.settings.getAll();
  483.   var captchaScript = settingsValues.captchaScript
  484.   captchaWindowAuto.webContents.executeJavaScript("var sessionNumber = " + sessionNumber + "; var checkoutURL = '" + checkoutURL + "';" + captchaScript)
  485.   captchaWindowAuto.webContents.executeJavaScript(`
  486.     function checkIfSolved() {
  487.       var ifrm = document.getElementsByTagName('iframe')[0];
  488.       if (ifrm != undefined) {
  489.           var win = ifrm.contentWindow; // reference to iframe's window
  490.           // reference to document in iframe
  491.           var doc = ifrm.contentDocument ? ifrm.contentDocument : ifrm.contentWindow.document;
  492.           // reference to form named 'demoForm' in iframe
  493.           try {
  494.             var form = doc.getElementsByClassName('recaptcha-checkbox-checkmark')[0];
  495.             if (form) {
  496.               ipcRenderer.send('loadNextAutoSolver', checkoutURL, sessionNumber)
  497.             }
  498.             // window.close()
  499.           } catch(e) {
  500.             setTimeout(checkIfSolved, 100)
  501.           }
  502.       } else {
  503.           setTimeout(checkIfSolved, 100)
  504.  
  505.       }
  506.  
  507.     }
  508.     function clickCaptcha() {
  509.         var ifrm = document.getElementsByTagName('iframe')[0];
  510.         if (ifrm != undefined) {
  511.             var win = ifrm.contentWindow; // reference to iframe's window
  512.             // reference to document in iframe
  513.             var doc = ifrm.contentDocument ? ifrm.contentDocument : ifrm.contentWindow.document;
  514.             // reference to form named 'demoForm' in iframe
  515.             try {
  516.               var form = doc.getElementsByClassName('rc-anchor-center-container')[1].click();
  517.               setTimeout(checkIfSolved, 500)
  518.             } catch(e) {
  519.               setTimeout(clickCaptcha, 500)
  520.             }
  521.         } else {
  522.             setTimeout(clickCaptcha, 500)
  523.  
  524.         }
  525.  
  526.     };
  527.     setTimeout(clickCaptcha, 700)`)
  528. }
  529.  
  530. ipcMain.on("loadAutoCaptchaToSolver", function(event, checkoutURL) {
  531.     loadCaptchaAuto(checkoutURL, 1)
  532. })
  533.  
  534. ipcMain.on("loadNextAutoSolver", function(event, checkoutURL, sessionNumber) {
  535.     var sessionNumber = sessionNumber + 1
  536.     loadCaptchaAuto(checkoutURL, sessionNumber)
  537. })
  538.  
  539. function waitForCaptchaAuto() {
  540.     try {
  541.         var settingsValues = app.ch.settings.getAll();
  542.         var captchas = JSON.parse(settingsValues.captchas)
  543.         for (i in captchas) {
  544.             if (captchas[i].token == "Not Solved") {
  545.                 loadCaptchaAuto(i.split("|")[0], i.split("|")[1])
  546.                 updateCaptchaFileScript("Being Solved", i.split("|")[0])
  547.             }
  548.         }
  549.         setTimeout(waitForCaptchaAuto, 500)
  550.     } catch (e) {
  551.         setTimeout(waitForCaptchaAuto, 500)
  552.     }
  553. }
  554.  
  555. //
  556.  
  557. function updateCaptchaFileScript(captchaToken, checkoutURL) {
  558.     var settingsValues = app.ch.settings.getAll()
  559.     try {
  560.         var captchaJSON = JSON.parse(settingsValues.captchas)
  561.     } catch (e) {
  562.         var captchaJSON = settingsValues.captchas
  563.     }
  564.     for (i in captchaJSON) {
  565.         if (i.indexOf(checkoutURL) >= 0) {
  566.             delete captchaJSON[i]
  567.         }
  568.     }
  569.     captchaJSON[checkoutURL] = {
  570.         token: captchaToken
  571.     }
  572.     app.ch.settings.set('captchas', JSON.stringify(captchaJSON));
  573. }
  574.  
  575. app.on('ready', function(){
  576.   createWaitWindow()
  577.   settings.init()
  578.   app.ch = {
  579.       settings
  580.   }
  581.   createActivationWindow()
  582. })
  583. ipcMain.on('autoSolveCaptcha', (event, checkoutURL) => {
  584.   loadAutoCaptcha(checkoutURL)
  585. })
  586.  
  587. app.on('window-all-closed', function () {
  588.     app.quit()
  589. })
  590.  
  591. app.on('activate', function () {
  592.   if (mainWindow === null) {
  593.     createWindow()
  594.  
  595.   }
  596. })
  597. availableCaptchaWindows = []
  598. ipcMain.on("toggleCaptchaWindow1", function(event) {
  599.     if ("1" in availableCaptchaWindows) {
  600.       delete availableCaptchaWindows["1"]
  601.     } else {
  602.       availableCaptchaWindows.push("1")
  603.     }
  604. })
  605. ipcMain.on("toggleCaptchaWindow2", function(event) {
  606.     if ("2" in availableCaptchaWindows) {
  607.       delete availableCaptchaWindows["2"]
  608.     } else {
  609.       availableCaptchaWindows.push("2")
  610.     }
  611. })
  612. ipcMain.on("toggleCaptchaWindow3", function(event) {
  613.     if ("3" in availableCaptchaWindows) {
  614.       delete availableCaptchaWindows["3"]
  615.     } else {
  616.       availableCaptchaWindows.push("3")
  617.     }
  618. })
  619. ipcMain.on("toggleCaptchaWindow4", function(event) {
  620.     if ("4" in availableCaptchaWindows) {
  621.       delete availableCaptchaWindows["4"]
  622.     } else {
  623.       availableCaptchaWindows.push("4")
  624.     }
  625. })
  626. ipcMain.on("toggleCaptchaWindow5", function(event) {
  627.     if ("5" in availableCaptchaWindows) {
  628.       delete availableCaptchaWindows["5"]
  629.     } else {
  630.       availableCaptchaWindows.push("5")
  631.     }
  632. })
  633. ipcMain.on("toggleCaptchaWindow6", function(event) {
  634.     if ("6" in availableCaptchaWindows) {
  635.       delete availableCaptchaWindows["6"]
  636.     } else {
  637.       availableCaptchaWindows.push("6")
  638.     }
  639. })
  640.  
  641. function createAutoCaptcha1() {
  642.   captchaAutoWindow1 = new BrowserWindow({
  643.       width: 500,
  644.       height: 600,
  645.       icon: __dirname + 'logo.png',
  646.       show: true,
  647.       minHeight: 500,
  648.       minWidth: 600,
  649.       webPreferences: {
  650.           webSecurity: false,
  651.           partition: 'persist:session1'
  652.       }
  653.   });
  654.   captchaAutoWindow1.loadURL("https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/", {userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"})
  655. }
  656. function createAutoCaptcha2() {
  657.   captchaAutoWindow2 = new BrowserWindow({
  658.       width: 500,
  659.       height: 600,
  660.       icon: __dirname + 'logo.png',
  661.       show: true,
  662.       minHeight: 500,
  663.       minWidth: 600,
  664.       webPreferences: {
  665.           webSecurity: false,
  666.           partition: 'persist:session2'
  667.       }
  668.   });
  669.   captchaAutoWindow2.loadURL("https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/", {userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"})
  670. }
  671.  
  672. function createAutoCaptcha3() {
  673.   captchaAutoWindow3 = new BrowserWindow({
  674.       width: 500,
  675.       height: 600,
  676.       icon: __dirname + 'logo.png',
  677.       show: true,
  678.       minHeight: 500,
  679.       minWidth: 600,
  680.       webPreferences: {
  681.           webSecurity: false,
  682.           partition: 'persist:session3'
  683.       }
  684.   });
  685.   captchaAutoWindow3.loadURL("https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/", {userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"})
  686. }
  687.  
  688. function createAutoCaptcha4() {
  689.   captchaAutoWindow4 = new BrowserWindow({
  690.       width: 500,
  691.       height: 600,
  692.       icon: __dirname + 'logo.png',
  693.       show: true,
  694.       minHeight: 500,
  695.       minWidth: 600,
  696.       webPreferences: {
  697.           webSecurity: false,
  698.           partition: 'persist:session4'
  699.       }
  700.   });
  701.   captchaAutoWindow4.loadURL("https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/", {userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"})
  702. }
  703.  
  704. function createAutoCaptcha5() {
  705.   captchaAutoWindow5 = new BrowserWindow({
  706.       width: 500,
  707.       height: 600,
  708.       icon: __dirname + 'logo.png',
  709.       show: true,
  710.       minHeight: 500,
  711.       minWidth: 600,
  712.       webPreferences: {
  713.           webSecurity: false,
  714.           partition: 'persist:session5'
  715.       }
  716.   });
  717.   captchaAutoWindow5.loadURL("https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/", {userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"})
  718. }
  719.  
  720. function createAutoCaptcha6() {
  721.   captchaAutoWindow6 = new BrowserWindow({
  722.       width: 500,
  723.       height: 600,
  724.       icon: __dirname + 'logo.png',
  725.       show: true,
  726.       minHeight: 500,
  727.       minWidth: 600,
  728.       webPreferences: {
  729.           webSecurity: false,
  730.           partition: 'persist:session6'
  731.       }
  732.   });
  733.   captchaAutoWindow6.loadURL("https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/", {userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25"})
  734. }
  735.  
  736.  
  737.  
  738. ipcMain.on('showAutoSolveCaptcha1', (event, checkoutURL) => {
  739.   createAutoCaptcha1()
  740. })
  741. ipcMain.on('showAutoSolveCaptcha2', (event, checkoutURL) => {
  742.   createAutoCaptcha2()
  743. })
  744. ipcMain.on('showAutoSolveCaptcha3', (event, checkoutURL) => {
  745.   createAutoCaptcha3()
  746. })
  747. ipcMain.on('showAutoSolveCaptcha4', (event, checkoutURL) => {
  748.   createAutoCaptcha4()
  749. })
  750. ipcMain.on('showAutoSolveCaptcha5', (event, checkoutURL) => {
  751.   createAutoCaptcha5()
  752. })
  753. ipcMain.on('showAutoSolveCaptcha6', (event, checkoutURL) => {
  754.   createAutoCaptcha6()
  755. })
  756.  
  757. ipcMain.on("openMainWindow", function(event, body) {
  758.     createMainWindow(body)
  759. })
  760. ipcMain.on("showActivationWindow", function(event) {
  761.     waitWindow.hide()
  762.     activationWindow.show()
  763. })
  764. ipcMain.on("showMainWindow", function(event) {
  765.     waitWindow.hide()
  766.     mainWindow.show()
  767. })
  768. ipcMain.on("minimizeMainWindow", function(event) {
  769.     mainWindow.minimize();
  770. })
  771. ipcMain.on('closeWindow', (event) => {
  772.     process.exit(1);
  773. })
  774. ipcMain.on('monitorUpdate', (event) => {
  775.     process.exit(1);
  776. })
  777. ipcMain.on('captchaSolved', (event, token, checkoutURL) => {
  778.     updateCaptchaFileScript(token, checkoutURL)
  779.     try {
  780.       captchaLoadScreen()
  781.     } catch(e) {}
  782. })
  783. ipcMain.on('openVisualMonitor', (event) => {
  784.   createMonitorWindow()
  785. })
  786. ipcMain.on('openCaptchaBox', (event) => {
  787.   createCaptchaWindow()
  788. })
  789. ipcMain.on('loadCaptchaBox', (event, token) => {
  790.   waitForCaptcha()
  791. })
  792. ipcMain.on('quickCreateRestockTaskToMain', (event, size, productURL, profile) => {
  793.   console.log(profile)
  794.   mainWindow.webContents.send('quickCreateRestockTask', size, productURL, profile)
  795. })
  796. //discord
  797. function createQuickTask(productURL){
  798.     mainWindow.webContents.send('quickCreateTaskMonitor', productURL)
  799. }
  800. function manualSolveCaptcha(checkoutURL){
  801.   var settingsValues = app.ch.settings.getAll();
  802.   if (captchaWindowOpen == false){
  803.       createCaptchaWindow()
  804.   }
  805.   try {
  806.       var captchas = JSON.parse(settingsValues.captchas)
  807.       for (i in captchas) {
  808.           if (i.indexOf(checkoutURL) >= 0) {
  809.               delete captchas[i]
  810.           }
  811.       }
  812.       app.ch.settings.set("captchas", JSON.stringify(captchas))
  813.   } catch (e) {}
  814.   updateCaptchaFileScript("Not Solved", checkoutURL)
  815. }
  816. ipcMain.on('manualSolveCaptcha', (event, checkoutURL) => {
  817.   var settingsValues = app.ch.settings.getAll();
  818.   if (captchaWindowOpen == false){
  819.       createCaptchaWindow()
  820.   }
  821.   try {
  822.       var captchas = JSON.parse(settingsValues.captchas)
  823.       for (i in captchas) {
  824.           if (i.indexOf(checkoutURL) >= 0) {
  825.               delete captchas[i]
  826.           }
  827.       }
  828.       app.ch.settings.set("captchas", JSON.stringify(captchas))
  829.   } catch (e) {}
  830.   updateCaptchaFileScript("Not Solved", checkoutURL)
  831. })
  832.  
  833. ipcMain.on('sendNeedCaptcha', (event, checkoutURL, autoCaptcha) => {
  834.     //event.sender.send('loadCaptcha', checkoutURL, autoCaptcha)
  835. })
  836. ipcMain.on('massLinkChange', (event, link) => {
  837.   mainWindow.webContents.send("massLinkChange", link)
  838. })
  839. ipcMain.on('openCheckoutFileExplorer', (event) => {
  840.   try {
  841.     var fileLocation = dialog.showOpenDialog({properties: ['openFile']})[0]
  842.     event.sender.send('loadProfiles', fileLocation)
  843.   } catch(e){
  844.  
  845.   }
  846. })
  847. ipcMain.on('checkCaptchaWindow', (event) => {
  848.     if (captchaWindowOpen == false){
  849.         createCaptchaWindow()
  850.     }
  851. })
  852. ipcMain.on('openCheckoutSaveFileExplorer', (event) => {
  853.     var fileLocation = dialog.showSaveDialog({properties: ['openFile']})
  854.     event.sender.send('exportProfiles', fileLocation)
  855. })
  856. ipcMain.on('openTasksFileExplorer', (event) => {
  857.   try {
  858.     var fileLocation = dialog.showOpenDialog({properties: ['openFile']})[0]
  859.     event.sender.send('loadTasks', fileLocation)
  860.   } catch(e){
  861.  
  862.   }
  863. })
  864. ipcMain.on('openTasksSaveFileExplorer', (event) => {
  865.     var fileLocation = dialog.showSaveDialog({properties: ['openFile']})
  866.     event.sender.send('exportTasks', fileLocation)
  867. })
  868. ipcMain.on('openPaypalCheckout', (event) => {
  869.  
  870.  
  871. })
  872. ipcMain.on('showPaypalWindow', (event) => {
  873.   paypalWindow
  874.       .show()
  875.       .goto("http://paypal.com")
  876.       .wait("#btnLogin")
  877.       .then(() =>  {
  878.     })
  879.       .catch(error => console.error(error))
  880. })
  881. ipcMain.on('startPaypalCheckout', (event, taskInfo) => {
  882.   var cookies = taskInfo.sessionJar._jar.store.idx
  883.   for (i in cookies) {
  884.       var cookieSite = cookies[i]
  885.   }
  886.   mainWindow.webContents.send('updateLog', taskInfo.taskNumber, "Checking Out With Paypal")
  887.   paypalWindow
  888.       .goto(taskInfo.siteURL)
  889.       .evaluate(function(cookieSite, paypalURL) {
  890.           for (i in cookieSite) {
  891.               for (i in cookieSite) {
  892.                   for (x in cookieSite[i]) {
  893.                       cookie = cookieSite[i][x]
  894.                       try {
  895.                           document.cookie = x + "=" + cookie.value;
  896.                       } catch (e) {}
  897.                   }
  898.               }
  899.           }
  900.           window.location.href = paypalURL
  901.           return "hi"
  902.       }, cookieSite, taskInfo.paypalURL)
  903.       .wait("#confirmButtonTop")
  904.       .wait(1500)
  905.       .evaluate(() => {
  906.         document.getElementById("confirmButtonTop").click()
  907.       })
  908.       .wait("#previous_step")
  909.       .evaluate(() => {
  910.         document.getElementsByClassName("step__footer__continue-btn btn")[0].click()
  911.       })
  912.       .then(() =>  {
  913.         mainWindow.webContents.send('updateLog', taskInfo.taskNumber, "Payment Submitted")
  914.     })
  915.       .catch(error => console.error(error))
  916.  
  917. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement