如何设置脚本只运行一次?油脂猴/坦帕猴 [英] How to set script only run one times? Greasemonkey/Tampermonkey
本文介绍了如何设置脚本只运行一次?油脂猴/坦帕猴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如.新标签页,并且包含网站的网址是相同的
For example. new tab and include website is the same url
// ==UserScript==
// @name _YOUR_SCRIPT_NAME
// @include https://stackoverflow.com/
// @grant GM_openInTab
// ==/UserScript==
var curTab = GM_openInTab ("https://stackoverflow.com/");
先访问SOF.com,然后再打开一个SOF.com新标签页
visit SOF.com after than open more one SOF.com new tab
推荐答案
这个问题不够明确,无法确定答案.这是一个基于可用信息的脚本示例:
The question is not clear enough for a definite answer. Here is a script example based on available information:
// ==UserScript==
// @name One Time
// @description Open New tab one time
// @match https://stackoverflow.com/
// @grant GM_openInTab
// @author erosman
// @version 1.0
// ==/UserScript==
if (!localStorage.getItem('oneTime')) {
localStorage.setItem('oneTime', 'true');
GM_openInTab('https://stackoverflow.com/');
}
这篇关于如何设置脚本只运行一次?油脂猴/坦帕猴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文