如何在“指定"选项卡中运行脚本,而不影响另一侧的选项卡(Greasemonkey/Tampermonkey) [英] How to run script in specify tab, and not effect the other side tab(Greasemonkey/Tampermonkey)

查看:126
本文介绍了如何在“指定"选项卡中运行脚本,而不影响另一侧的选项卡(Greasemonkey/Tampermonkey)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在指定"选项卡中运行脚本,而不影响另一侧的选项卡?

How to run script in specify tab, and not effect the other side tab?

像第一个标签一样,继续自动刷新example.com

like first tab keep going auto-refresh example.com

同时打开新标签页访问example.com(非自动刷新)吗?

as the same time new tab visit example.com(Non auto-refresh)?

#Greasemonkey #Tampermonkey

#Greasemonkey #Tampermonkey

// ==UserScript==
// @name     Auto-Refresh
// @include  https://www.example.com
// ==/UserScript==

setTimeout(function(){ location.reload(); }, 5000);

推荐答案

问题还不够清楚,无法确定答案.

The question is not clear enough for a definite answer.

用户脚本通常无权访问TAB数据来知道它们在哪个选项卡上运行.

User-scripts normally do not have access to TAB data to know which tab they are running on.

在用户脚本管理器(GreaseMonkey,ViolentMonkey,TamperMonkey和FireMoneky)中,只有ATM的TamperMonkey具有GM_getTab& GM_getTabs API(非标准)以获取有关运行脚本的选项卡的详细信息.因此,这种解决方案仅适用于TamperMonkey.

Among user-script managers (GreaseMonkey, ViolentMonkey, TamperMonkey & FireMoneky), ATM only TamperMonkey has GM_getTab & GM_getTabs API (Non-standard) to get details about the tab that script runs on. Therefore such solution would only work on TamperMonkey.

此外,location.reload()也使其变得更加困难.

Furthermore, the location.reload() also makes it more difficult.

是真实代码还是location.reload()只是示例?

Is that the real code or location.reload() is just an example?

这篇关于如何在“指定"选项卡中运行脚本,而不影响另一侧的选项卡(Greasemonkey/Tampermonkey)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆