This utility is designed to ease authoring user scripts compatible with both Greasemonkey 4 and other/older user script engines.
Include it in your script like:
// @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
Read the source of the file for more details.