Last active
March 8, 2022 15:31
-
-
Save arantius/5b25e120d38506021c4528d2df55feb4 to your computer and use it in GitHub Desktop.
A simple persistent value test user script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// ==UserScript== | |
// @name GM set/get demo | |
// @description Exercises both GM.getValue() and GM.getValue(). Logs a counter which goes up by one, at each page load. | |
// @grant GM.getValue | |
// @grant GM_getValue | |
// @grant GM.setValue | |
// @grant GM_setValue | |
// @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js | |
// ==/UserScript== | |
async function getSetDemo() { | |
console.log('Starting the get/set demo ...'); | |
let i = await GM.getValue('i', 0); | |
console.log(`This time, i was ${i}.`); | |
GM.setValue('i', i+1); | |
} | |
getSetDemo(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment