Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activate Firefox tab in Greasemonkey/Javascript? Is this possible?

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.

like image 439
Logan Serman Avatar asked May 01 '26 10:05

Logan Serman


2 Answers

I'm pretty sure that firefox gives focus to tabs that call alert(). So just pop up an
alert('found foo')

like image 189
Ovesh Avatar answered May 04 '26 01:05

Ovesh


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.

like image 40
erikvold Avatar answered May 04 '26 01:05

erikvold