Skip to content

Commit

Permalink
Re-enable grant sniffing!
Browse files Browse the repository at this point in the history
The world (meaning I) is not ready get for @grant :p
Closes GH-226 (and probably numerous others)
Reverts part of 0f767fa
  • Loading branch information
nmaier committed Jul 15, 2014
1 parent a3a7b39 commit 63a4ad6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions extension/content/options.xul
Expand Up @@ -106,6 +106,7 @@
<preference id="pref-logChrome" name="extensions.scriptish.logChrome" type="bool"/>
<preference id="pref-logToErrorConsole" name="extensions.scriptish.logToErrorConsole" type="bool"/>
<preference id="pref-enableScriptGrant" name="extensions.scriptish.enableScriptGrant" type="bool"/>
<preference id="pref-enableScriptGrantSniffing" name="extensions.scriptish.enableScriptGrantSniffing" type="bool"/>
<preference id="pref-enableInstallDetection" name="extensions.scriptish.enableInstallDetection" type="bool"/>
<preference id="pref-update-requireSecured" name="extensions.scriptish.update.requireSecured" type="bool"/>
<preference id="pref-update-requireBuiltInCerts" name="extensions.scriptish.update.requireBuiltInCerts" type="bool"/>
Expand All @@ -131,6 +132,7 @@
<groupbox>
<caption label="options.other" localize="label" />
<checkbox preference="pref-enableScriptGrant" label="options.grant.enabled" localize="label"/>
<checkbox preference="pref-enableScriptGrantSniffing" label="options.grant.sniffing" localize="label"/>
<checkbox preference="pref-enableInstallDetection" label="options.enableInstallDetection" localize="label"/>
</groupbox>
</tabpanel>
Expand Down
1 change: 1 addition & 0 deletions extension/defaults/preferences/scriptish.js
Expand Up @@ -18,6 +18,7 @@ pref("extensions.scriptish.enabledNotifications.popup", true);
pref("extensions.scriptish.enabledNotifications.sliding", true);
pref("extensions.scriptish.enableScriptRefreshing", true);
pref("extensions.scriptish.enableScriptGrant", true);
pref("extensions.scriptish.enableScriptGrantSniffing", true);
pref("extensions.scriptish.enableInstallDetection", true);
pref("extensions.scriptish.logChrome", false);
pref("extensions.scriptish.logToErrorConsole", true);
Expand Down
1 change: 1 addition & 0 deletions extension/locale/en-US/scriptish.properties
Expand Up @@ -125,6 +125,7 @@ options.excludes.desc=Global excludes will override any script or user specified
options.excludes.empty=No global excludes specified
options.excludes.remark=(You may specify one exclude per line)
options.grant.enabled=Enable @grant
options.grant.sniffing=Enable @grant sniffing
options.logChrome=Log non-critical extension messages to the Error Console
options.logging=Logging
options.logToErrorConsole=GM_log uses the Error Console
Expand Down
6 changes: 6 additions & 0 deletions extension/modules/script/script.js
@@ -1,6 +1,7 @@
var EXPORTED_SYMBOLS = ["Script"];

const valueSplitter = /(\S+)(?:\s+([^\r\f\n]+))?/;
const GRANT_REGEX = /(?:unsafeWindow|GM_[a-z]+)/gi;

const Cu = Components.utils;
Cu.import("resource://gre/modules/CertUtils.jsm");
Expand Down Expand Up @@ -919,6 +920,11 @@ Script.parse = function Script_parse(aConfig, aSource, aURI, aUpdateScript, aPri
if (aURI && aPrivate === false)
script._downloadURL = aURI.spec;

// sniff @grant ?
if (Scriptish_prefRoot.getValue("enableScriptGrantSniffing")) {
(aSource.match(GRANT_REGEX) || []).forEach(function(i) script.grant[i] = true);
}

// read one line at a time looking for start meta delimiter or EOF
var lines = aSource.match(metaRegExp);
var i = 0;
Expand Down

0 comments on commit 63a4ad6

Please sign in to comment.