Activate Firefox tab in Greasemonkey/Javascript? Is this possible?
-
11-07-2019 - |
Question
I developed a greasemonkey script that refreshes a page and checks for certain updates. I would like to run this script in a tab and browse the internet in another tab, but then have the script automatically activate it's tab when an update is found.
Im not sure how clear that was, maybe this is better:
Tab 1 is running a greasemonkey script, refreshing every x seconds looking for the word "foo"
Tab 2 is browsing stackoverflow
-- Now on a refresh, the GM script finds the word "foo". This is when I want the tab focus to automatically shift from Tab 2 to Tab 1.
Is this possible, and if so, how do I achieve this?
Thanks.
Solution
I'm pretty sure that firefox gives focus to tabs that call alert()
. So just pop up an
alert('found foo')
OTHER TIPS
You can achieve this with Scriptish's GM_openInTab
implementation, like so:
GM_openInTab(window.location.href, true);
That should cause the page that a GM script is on to be focused.
Have you looked at GM_openInTab()?