Please forgive me if this has been answered before but I've searched and searched and haven't been able to find a solution to my problem.
I'm using Greasemonkey in Firefox and Tampermonkey in Chrome to automatically open a link on a webpage I visit frequently. Below is the javascript code:
// ==/UserScript==
var link = document.querySelector('[href*="/cgi/admin/user/ssh_login/"]');
var url = link.getAttribute('href');
var sshlink = "https://"+document.domain+url;
//alert(sshlink);
var openWindow = window.open(sshlink,"ssh","location=1,status=1,scrollbars=1,width=100,height=100");
window.blur();
setTimeout(function(){openWindow.close();},2000);
This opens the link in a new popup and closes it after 2000ms. What I'd actually prefer is to have the openWindow.close();
happen after the popup's window.open is done loading. I've tried both of these solutions and neither have worked.
What am I doing wrong? Does anyone know what I can do differently to accomplish what I want?