我开发了一个greasemonkey 脚本来刷新页面并检查某些更新。 我想在一个选项卡中运行此脚本并在另一个选项卡中浏览互联网,但是当发现更新时让脚本自动激活其选项卡。
我不确定这有多清楚,也许这样更好:
选项卡 1 正在运行 Greasemonkey 脚本,每 x 秒刷新一次,查找单词“foo”
选项卡 2 正在浏览 stackoverflow
- 现在刷新,GM 脚本会找到该单词“富”。 这是当我希望选项卡焦点自动从选项卡 2 转移到选项卡 1 时。
这可能吗?如果可以,我该如何实现这一点?
谢谢。
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.
发布评论
评论(3)
我非常确定 Firefox 会将焦点放在调用
alert()
的选项卡上。 所以只需弹出一个alert('发现 foo')
I'm pretty sure that firefox gives focus to tabs that call
alert()
. So just pop up analert('found foo')
您可以使用 Scriptish 的
GM_openInTab
实现,如下所示:这应该会导致 GM 脚本所在的页面保持专注。
You can achieve this with Scriptish's
GM_openInTab
implementation, like so:That should cause the page that a GM script is on to be focused.
你看过GM_openInTab()吗?
Have you looked at GM_openInTab()?