如何设置脚本只运行一次? Greasemonkey/Tampermonkey

How to set script only run one times? Greasemonkey/Tampermonkey

例如。新标签和包含网站是一样的url

// ==UserScript==
// @name     _YOUR_SCRIPT_NAME
// @include  https://whosebug.com/
// @grant    GM_openInTab
// ==/UserScript==

var curTab  = GM_openInTab ("https://whosebug.com/");

访问 SOF.com 比打开更多 SOF.com 新标签

问题不够明确,无法给出明确的答案。这是一个基于可用信息的脚本示例:

// ==UserScript==
// @name          One Time
// @description   Open New tab one time
// @match         https://whosebug.com/
// @grant         GM_openInTab
// @author        erosman
// @version       1.0
// ==/UserScript==

if (!localStorage.getItem('oneTime')) {
  
  localStorage.setItem('oneTime', 'true');
  GM_openInTab('https://whosebug.com/');
}