问题
How to run script in specify tab, and not effect the other side tab?
like first tab keep going auto-refresh example.com
as the same time new tab visit example.com(Non auto-refresh)?
#Greasemonkey #Tampermonkey
// ==UserScript==
// @name Auto-Refresh
// @include https://www.example.com
// ==/UserScript==
setTimeout(function(){ location.reload(); }, 5000);
回答1:
The question is not clear enough for a definite answer.
User-scripts normally do not have access to TAB data to know which tab they are running on.
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.
Furthermore, the location.reload()
also makes it more difficult.
Is that the real code or location.reload()
is just an example?
来源:https://stackoverflow.com/questions/62913789/how-to-run-script-in-specify-tab-and-not-effect-the-other-side-tabgreasemonkey