-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtinder.js
More file actions
46 lines (36 loc) · 1.58 KB
/
Copy pathtinder.js
File metadata and controls
46 lines (36 loc) · 1.58 KB
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
const puppeteer = require('puppeteer');
var fs = require('fs');
var fileExists;
var step;
const cookiesPath = 'tindercookies.txt';
fs.exists(cookiesPath, function(exists) {
console.log("file exists ? " + exists);
fileExists=exists;
});
(async () => {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();
const context = browser.defaultBrowserContext();
context.overridePermissions("https://www.facebook.com", ["geolocation", "notifications"])
if (fileExists) {
console.log('File exists');
const content = fs.readFileSync(cookiesPath);
const cookiesArr = JSON.parse(content);
if (cookiesArr.length !== 0) {
for (let cookie of cookiesArr) {
await page.setCookie(cookie)
}
console.log('Session has been loaded in the browser')
}
await page.goto('https://tinder.com/app/recs', { "waitUntil": "load" });
console.log("------------------------------------------------finishing the if statement")
}
else{
await page.goto('https://tinder.com', { "waitUntil": "load" });
await page.waitFor(30000);
console.log("------------------------------------------------finishing the else statement")
const cookiesObject = await page.cookies()
fs.writeFileSync(cookiesPath, JSON.stringify(cookiesObject));
console.log('Session has been saved to ' + cookiesPath);
}
})()