-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhint.js
53 lines (43 loc) · 1.45 KB
/
hint.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
const puppeteer = require("puppeteer");
// JWT for user "admin", signed with key "jwt secret"
const JWT = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIn0.rJiXjoimcdCR6d6CwXzB4jY9dHP1YbBraTCRWeYJksU";
const SITE = process.env.SITE || "https://notekeeper.mc.ax";
const visit = async (url) => {
let browser;
try {
browser = await puppeteer.launch({
headless: true,
pipe: true,
args: [
"--no-sandbox",
"--disable-setuid-sandbox",
"--js-flags=--noexpose_wasm,--jitless",
],
dumpio: true
});
let page = await browser.newPage();
await page.goto(url);
await page.waitForTimeout(4000);
// nice page... oh man i should check my notes!!!
await page.setCookie({
name: 'session',
value: JWT,
domain: new URL(SITE).host,
httpOnly: true
});
await page.goto(SITE + "/home");
await page.waitForTimeout(4000);
// looks good to me!!
await page.evaluate(() => {
document.querySelector("#logout") && document.querySelector("#logout").click();
});
await page.waitForNavigation();
await browser.close();
browser = null;
} catch (err) {
console.log(err);
} finally {
if (browser) await browser.close();
}
};
module.exports = { visit };