Skip to content

Commit

Permalink
Style clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
janekptacijarabaci committed Aug 22, 2015
1 parent 022e6db commit 570b05a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
15 changes: 8 additions & 7 deletions modules/parseScript.js
Expand Up @@ -20,10 +20,10 @@ var gStringBundle = Components
.createBundle("chrome://greasemonkey/locale/greasemonkey.properties");

var GM_GUID = "{e4a8a97b-f2ed-450b-b12d-ee082ba24781}";
var gGreasemonkeyVersion = 'unknown';
var gGreasemonkeyVersion = "unknown";
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID(GM_GUID, function(addon) {
gGreasemonkeyVersion = '' + addon.version;
gGreasemonkeyVersion = "" + addon.version;
});

/** Get just the stuff between ==UserScript== lines. */
Expand Down Expand Up @@ -166,8 +166,8 @@ function parse(aSource, aUri, aFailWhenMissing, aNoMetaOk) {
case 'minFFVer':
if ((null !== value) && (GM_util.compareFirefoxVersion(value) < 0)) {
script.parseErrors.push(
gStringBundle.GetStringFromName('parse.ff-failed')
.replace('%1', value)
gStringBundle.GetStringFromName('parse.ff-failed')
.replace('%1', value)
);
}
script._minFFVer = value;
Expand All @@ -176,10 +176,11 @@ function parse(aSource, aUri, aFailWhenMissing, aNoMetaOk) {
var versionChecker = Components
.classes["@mozilla.org/xpcom/version-comparator;1"]
.getService(Components.interfaces.nsIVersionComparator);
if ((null !== value) && (versionChecker.compare(gGreasemonkeyVersion, value) < 0)) {
if ((null !== value)
&& (versionChecker.compare(gGreasemonkeyVersion, value) < 0)) {
script.parseErrors.push(
gStringBundle.GetStringFromName('parse.gm-failed')
.replace('%1', value)
gStringBundle.GetStringFromName('parse.gm-failed')
.replace('%1', value)
);
}
script._minGMVer = value;
Expand Down
34 changes: 18 additions & 16 deletions modules/util/scriptMatchesUrlAndRuns.js
Expand Up @@ -8,27 +8,28 @@ var gStringBundle = Components
.createBundle("chrome://greasemonkey/locale/greasemonkey.properties");

var GM_GUID = "{e4a8a97b-f2ed-450b-b12d-ee082ba24781}";
var gGreasemonkeyVersion = 'unknown';
var gGreasemonkeyVersion = "unknown";
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID(GM_GUID, function(addon) {
gGreasemonkeyVersion = '' + addon.version;
gGreasemonkeyVersion = "" + addon.version;
});

function scriptMatchesUrlAndRuns(script, url, when) {
var result = !script.pendingExec.length
&& script.enabled
&& !script.needsUninstall
&& (script.runAt == when || 'any' == when)
&& script.matchesURL(url);
&& script.enabled
&& !script.needsUninstall
&& (script.runAt == when || "any" == when)
&& script.matchesURL(url);

var minFFVer = true;
var minGMVer = true;

if (result && ('null' !== script.minFFVer) && (GM_util.compareFirefoxVersion(script.minFFVer) < 0)) {
if (result && ("null" !== script.minFFVer)
&& (GM_util.compareFirefoxVersion(script.minFFVer) < 0)) {
GM_util.logError(
gStringBundle.GetStringFromName('run.ff-failed')
.replace('%1', script.name)
.replace('%2', script.minFFVer),
gStringBundle.GetStringFromName("run.ff-failed")
.replace('%1', script.name)
.replace('%2', script.minFFVer),
true, // is a warning
script.fileURL,
null
Expand All @@ -39,11 +40,12 @@ function scriptMatchesUrlAndRuns(script, url, when) {
var versionChecker = Components
.classes["@mozilla.org/xpcom/version-comparator;1"]
.getService(Components.interfaces.nsIVersionComparator);
if (result && ('null' !== script.minGMVer) && (versionChecker.compare(gGreasemonkeyVersion, script.minGMVer) < 0)) {
if (result && ("null" !== script.minGMVer)
&& (versionChecker.compare(gGreasemonkeyVersion, script.minGMVer) < 0)) {
GM_util.logError(
gStringBundle.GetStringFromName('run.gm-failed')
.replace('%1', script.name)
.replace('%2', script.minGMVer),
gStringBundle.GetStringFromName("run.gm-failed")
.replace('%1', script.name)
.replace('%2', script.minGMVer),
true, // is a warning
script.fileURL,
null
Expand All @@ -52,6 +54,6 @@ function scriptMatchesUrlAndRuns(script, url, when) {
}

return result
&& minFFVer
&& minGMVer;
&& minFFVer
&& minGMVer;
}

0 comments on commit 570b05a

Please sign in to comment.