Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Allows userscript files to work both as Greasemonkey scripts, and as BabelExt extensions
// Basically, dynamically selects between BabelExt and Greasemonkey methods,
// depending on what is avalaible at runtime
// Simply put this at the top of your userscript, and use BE_set/getValue
// exactly as you would
// However, there is also another argument passed to getValue, def, as in the
// default value if none can be retrieved (as in Greasemonkey's GM_getValue)
function BE_setValue(key, val, callback) {
if (typeof(BabelExt) != 'undefined') {, val, callback);
} else {
GM_setValue(key, val);;
function BE_getValue(key, def, callback) {
if (typeof(BabelExt) != 'undefined') {, callback);
} else {, GM_getValue(key, def));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.