-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
67 lines (52 loc) · 2.1 KB
/
index.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
const app = require('express')();
const axios = require("axios").default;
const puppeteer = require('puppeteer-extra').default;
const pluginStealth = require('puppeteer-extra-plugin-stealth');
const { executablePath } = require('puppeteer');
var browser = null;
async function run() {
puppeteer.use(pluginStealth());
browser = await puppeteer.launch({
headless: false,
executablePath: executablePath(),
args: ['--window-position=000,000', '--no-sandbox', '--disable-dev-shm-usage', '--disable-web-security', '--disable-features=IsolateOrigins', ' --disable-site-isolation-trials']
});
const page = await browser.newPage();
await page.setRequestInterception(true);
page.on('request', async (request) => {
if (request.url().includes("https://cumsdtu.in/LSARegistration/api/getStuRegistration") || request.url().includes("https://cumsdtu.in/LSARegistration/api/saveSchedule")) {
try {
const res = await axios.get(request.url(), { headers: request.headers() });
var resdata = res.data;
resdata.data.extraInfo = "Set Compulsory [1 more courses], Group GEC4 [1 more Set(s)]";
resdata.data.extraValueMap["IS_VIEW_ONLY"] = true;
await request.respond({
ok: true,
status: 200,
url: request.url(),
contentType: 'application/json;charset=UTF-8',
body: JSON.stringify(resdata)
});
} catch (error) {
console.log(error);
request.continue();
}
} else {
request.continue();
}
});
await page.goto("https://cumsdtu.in/registration_student/login/login.jsp?courseRegistration");
}
app.get("/", (req, res) => {
res.send("What are you doing here");
});
process.on('SIGINT', () => {
console.log('bye!');
browser.close();
process.exit()
});
app.listen(8000, async (err) => {
if (err) return;
console.log('Server Running onPOrt : ', 8000);
await run();
});