Because some userscript managers keep using the old GM_*
functions and some insist on the new async functions, there is an issue when building scripts for both of these. This helper script fixes that by adding a polyfill for the asynchronous functions.
const GM = require('./gm_functions.js');
GM.setValue('username', 'My name!')
.then(e => GM.getValue('username'))
.then(e => console.log(e)); // My name!
Originally I wanted to use https://github.com/greasemonkey/gm4-polyfill to provide compatibility between the new async greasemonkey functions and the old GM_* functions. But in order to keep this project purely public domain, I could not use their MIT licensed code.
This is an attempt at providing the same functionality, while being separate from that work. I understand how the old version functions but this will be my own unique creation, free from their license.
All code in this repository is licensed under the Unlicense and is in the Public Domain.