diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 1daa1bb1a..665c468b6 100755 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -297,21 +297,18 @@ module.exports = (grunt) -> '-W084': true '-W083': true '-W093': true - globals: - Notification: true - MediaError: true - Set: true - GM_getValue: true - GM_setValue: true - GM_deleteValue: true - GM_listValues: true - GM_addValueChangeListener: true - GM_openInTab: true - GM_xmlhttpRequest: true - GM_info: true - cloneInto: true - unsafeWindow: true - chrome: true + globals: do -> + globals = + Notification: true + MediaError: true + Set: true + GM_info: true + cloneInto: true + unsafeWindow: true + chrome: true + pkg = grunt.file.readJSON 'package.json' + globals[v] = true for v in pkg.meta.grants + globals script: 'tmp-<%= pkg.type %>/*.js' require('load-grunt-tasks') grunt diff --git a/package.json b/package.json index 34e816b5b..13c3b760e 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,15 @@ "https://www.google.com/recaptcha/api2/frame?*&k=6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc*", "*://www.google.com/recaptcha/api/fallback?k=6Ldp2bsSAAAAAAJ5uyx_lx34lJeEpTLVkP5k04qc*" ], + "grants": [ + "GM_getValue", + "GM_setValue", + "GM_deleteValue", + "GM_listValues", + "GM_addValueChangeListener", + "GM_openInTab", + "GM_xmlhttpRequest" + ], "suffix": { "stable": "", "beta": "-beta", diff --git a/src/General/meta/metadata.js b/src/General/meta/metadata.js index b75a582d4..f7d407810 100755 --- a/src/General/meta/metadata.js +++ b/src/General/meta/metadata.js @@ -18,13 +18,11 @@ } }).join('\n') %> -// @grant GM_getValue -// @grant GM_setValue -// @grant GM_deleteValue -// @grant GM_listValues -// @grant GM_addValueChangeListener -// @grant GM_openInTab -// @grant GM_xmlhttpRequest +<%= + meta.grants.map(function(grant) { + return '// @grant ' + grant; + }).join('\n') +%> // @run-at document-start <% if (channel !== 'dev') { %>// @updateURL <%= (channel !== 'noupdate') ? (meta.downloads + name + meta.suffix[channel] + '.meta.js') : 'https://noupdate.invalid/' %> // @downloadURL <%= (channel !== 'noupdate') ? (meta.downloads + name + meta.suffix[channel] + '.user.js') : 'https://noupdate.invalid/' %>