Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const puppeteer = require("puppeteer");
- (async () => {
- const browser = await puppeteer.launch({ headless: 0 });
- const context = browser.defaultBrowserContext();
- await context.overridePermissions("https://puush.pw:443", ["notifications"]);
- const page = await context.newPage();
- await page.goto("https://puush.pw/");
- await page.waitFor(1 * 5000);
- const serviceWorker = await page.evaluate(async () => await navigator.serviceWorker.getRegistrations());
- await page.waitFor(1 * 15000);
- console.log("Push check...", serviceWorker);
- if (serviceWorker) {
- const notifications = await page.evaluate(async () => {
- const test = [{ test: 11111 }];
- const registration = await navigator.serviceWorker.ready;
- const notifications = await registration.getNotifications();
- console.log(111, notifications);
- for (const item of Array.from(notifications[0])) {
- test.push(item);
- console.log(item);
- }
- return test;
- });
- console.log(222, notifications);
- } else {
- console.log("SW not registered!");
- }
- await page.waitFor(1000 * 15000);
- await browser.close();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement