如何在第一次运行 greasemonkey 脚本时运行函数?
最佳答案
您可以使用GM_setValue
和GM_getValue
来存储设置等。
尝试“获得”一面旗帜。如果未设置,请进行第一次运行调用,然后设置该值。例如
var isfirstrun = GM_getValue('firstrun', '0');
if (isfirstrun == '0')
{
// value not set, so must be the first run
DoSomething();
GM_setValue('firstrun', '1');
}
文档是 here
关于javascript - 首次运行 Greasemonkey 脚本时执行函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1714477/