'Solution to stay logged in using javascript/puppeteer

There are some intranet sites that log me out more often than I like and I tried using Python, PowerShell and Javascript. The last one worked but it was based on launching those sites in child/popup windows which caused the focus to keep returning to those pages. I then looked at Puppeteer to do this using a headless Edge session.

  1. I am not a developer - just know how to write short scripts
  2. I am open to any Windows-based solution as I am not allowed to use Linux
  3. The following is what I tried with Puppeteer (against MS Edge (chromium)):
const puppeteer = require("puppeteer-core");
const edgePaths = require("edge-paths");
const EDGE_PATH = edgePaths.getEdgePath();

async function loadTabs(){
    const browser = await puppeteer.launch({executablePath: EDGE_PATH});
    const url1 = await browser.newPage();
    const url2 = await browser.newPage();

    await url1.goto("https://url1");
    await url2.goto("https://url2");

    await delay(3000);
    await browser.close();
}

function delay(time){
    return new Promise(function(resolve){
        setTimeout(resolve, time)
    });
}

loadTabs();

The script is cobbled together from what I found about Puppeteer and JavaScript but I make no claim to this being even set up correctly.

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source