-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get_Master_Script.js
77 lines (64 loc) · 3.11 KB
/
Get_Master_Script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
function delay(time) {
return new Promise(function(resolve) {
setTimeout(resolve, time)
});
}
(async () => {
require('dotenv').config()
const path = require('path')
const downloadPath = path.resolve('./')
// console.log(downloadPath)
const puppeteer = require('puppeteer')
// const browser = await puppeteer.launch({
// headless: false,
// args: [
// '--incognito',
// ],
// })
// const page = await browser.newPage()
const browser = await puppeteer.launch({headless: true})
const context = await await browser.createIncognitoBrowserContext()
const page = await context.newPage()
console.log(browser.defaultBrowserContext().isIncognito())
await page.goto('https://web.quantsapp.com/signin')
await page.setViewport({ width: 1517, height: 773 })
await page.waitForSelector('#mat-input-1')
await page.click('#mat-input-1')
await page.focus('#mat-input-1')
await page.type("#mat-input-1", process.env.USER_NAME, {delay: 100})
await page.waitForSelector('#mat-input-2')
await page.click('#mat-input-2')
await page.focus('#mat-input-2')
await page.type("#mat-input-2", process.env.PASSWORD, {delay: 100})
await page.waitForSelector('.ng-star-inserted > #slide > .login-form > .ng-dirty > .login-btn')
await page.click('.ng-star-inserted > #slide > .login-form > .ng-dirty > .login-btn')
await page._client().send('Page.setDownloadBehavior', {behavior: 'allow', downloadPath: downloadPath})
await page.waitForTimeout(20000)
// await delay(4000);
await page.evaluate(() => {
function download(content, fileName, contentType) {
var a = document.createElement("a");
var file = new Blob([content], {type: contentType});
a.href = URL.createObjectURL(file);
a.download = fileName;
a.click();
}
download(localStorage.masterScript, 'masterScript.json', 'applicatin/json');
download(localStorage.rawMS, 'rawMS.json', 'text/plain');
download(localStorage.masterScriptVersion, 'masterScriptVersion.json', 'text/plain');
download(localStorage.marketTimings, 'marketTimings.json', 'text/plain');
// download(localStorage.lastExpiry, 'lastExpiry.json', 'text/plain');
})
// await page.waitForSelector('#profileMenuBtn')
// await page.click('#profileMenuBtn')
// await page.waitForSelector('#mat-menu-panel-0 > div')
// await page.click('#mat-menu-panel-0 > div')
// await page.waitForSelector('#mat-menu-panel-0 > div > button:nth-child(9)')
// await page.click('#mat-menu-panel-0 > div > button:nth-child(9)')
// await page.waitForSelector('#mat-dialog-0')
// await page.click('#mat-dialog-0')
// await page.waitForSelector('#mat-dialog-0 > app-common-dialog > div > div:nth-child(1) > div:nth-child(3) > button:nth-child(1)')
// await page.click('#mat-dialog-0 > app-common-dialog > div > div:nth-child(1) > div:nth-child(3) > button:nth-child(1)')
await page.waitForTimeout(10000)
await browser.close()
})()