迁移部分内容
Some checks failed
test / Run tests (push) Failing after 55s
build / Build (push) Failing after 1m18s
Some checks failed
test / Run tests (push) Failing after 55s
build / Build (push) Failing after 1m18s
This commit is contained in:
32
example/gm_value.js
Normal file
32
example/gm_value.js
Normal file
@@ -0,0 +1,32 @@
|
||||
// ==UserScript==
|
||||
// @name gm value
|
||||
// @namespace https://bbs.tampermonkey.net.cn/
|
||||
// @version 0.1.0
|
||||
// @description 可以持久化存储数据, 并且可以监听数据变化
|
||||
// @author You
|
||||
// @match https://bbs.tampermonkey.net.cn/
|
||||
// @run-at document-start
|
||||
// @grant GM_setValue
|
||||
// @grant GM_getValue
|
||||
// @grant GM_addValueChangeListener
|
||||
// @grant GM_listValues
|
||||
// @grant GM_deleteValue
|
||||
// @grant GM_cookie
|
||||
// ==/UserScript==
|
||||
|
||||
GM_addValueChangeListener("test_set", function (name, oldval, newval, remote, tabid) {
|
||||
GM_cookie("store", tabid,(storeId) => {
|
||||
console.log("store",storeId);
|
||||
});
|
||||
});
|
||||
|
||||
setInterval(() => {
|
||||
console.log(GM_getValue("test_set"));
|
||||
console.log(GM_listValues());
|
||||
}, 2000);
|
||||
|
||||
setTimeout(() => {
|
||||
GM_deleteValue("test_set");
|
||||
}, 3000);
|
||||
|
||||
GM_setValue("test_set", new Date().getTime());
|
Reference in New Issue
Block a user