Disclaimer: I don't actually expect this is possible due to security issues, but before I give up entirely I had to ask: Is it possible, using a Javascript bookmarklet, to open a window to a URL and have it auto close after that content has loaded?
My usage is to temporarily disable Pi-hole using it's API. The current code I have works on a simple timeout, but I'd like to have it ensure the page loaded before closing the window.
Here's my (expanded) code at the moment:
(() => {
t = prompt('Disable time (seconds)',30);
if (t) {
w = window.open(`http://___IP___/admin/api.php?disable=${t}&auth=___APIKEY___`,'pi-disable','left=20,top=20,width=300,height=200');
setTimeout(() => w.close(), 1000);
}
})()
In case it's not obvious, I don't control the URL output so I can't add script there to have it close, otherwise this would be a non-issue. And for reference, the output is just a JSON string: {"status":"disabled"}
Just for kicks, I tried using fetch() or adding an iframe, but as expected those presented other issues (Mixed Content, CORS policy, etc).