Skip to content

Commit

Permalink
Move getEnabled into an util module.
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Lieuallen committed Aug 22, 2011
1 parent 37a705b commit d6dd73a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions components/greasemonkey.js
Expand Up @@ -279,7 +279,7 @@ service.prototype.shouldLoad = function(ct, cl, org, ctx, mt, ext) {
var ret = Ci.nsIContentPolicy.ACCEPT;

// Don't intercept anything when GM is not enabled.
if (!GM_getEnabled()) {
if (!GM_util.getEnabled()) {
return ret;
}

Expand Down Expand Up @@ -363,7 +363,7 @@ service.prototype.runScripts = function(
aRunWhen, aWrappedContentWin, aChromeWin
) {
var url = aWrappedContentWin.document.location.href;
if (!GM_getEnabled() || !GM_util.isGreasemonkeyable(url)) return;
if (!GM_util.getEnabled() || !GM_util.isGreasemonkeyable(url)) return;

if (GM_prefRoot.getValue('enableScriptRefreshing')) {
this._config.updateModifiedScripts(aWrappedContentWin, aChromeWin);
Expand Down
4 changes: 2 additions & 2 deletions content/browser.js
Expand Up @@ -101,7 +101,7 @@ GM_BrowserUI.chromeLoad = function(e) {
};

GM_BrowserUI.contentLoad = function(event) {
if (!GM_getEnabled()) return;
if (!GM_util.getEnabled()) return;

var safeWin = event.target.defaultView;
var href = safeWin.location.href;
Expand Down Expand Up @@ -287,7 +287,7 @@ GM_BrowserUI.refreshStatus = function() {
var enabledEl = document.getElementById("gm_toggle_enabled");
var checkedEl = document.getElementById("gm_toggle_checked");

if (GM_getEnabled()) {
if (GM_util.getEnabled()) {
checkedEl.setAttribute('checked', true);
enabledEl.removeAttribute('disabled');
} else {
Expand Down
4 changes: 2 additions & 2 deletions content/browser.xul
Expand Up @@ -16,9 +16,9 @@

<commandset>
<!-- sync the 'disabled' attribute for toolbar button -->
<command id="gm_toggle_enabled" oncommand="GM_setEnabled(!GM_getEnabled());"/>
<command id="gm_toggle_enabled" oncommand="GM_setEnabled(!GM_util.getEnabled());"/>
<!-- sync the 'checked' attribute for menu items -->
<command id="gm_toggle_checked" oncommand="GM_setEnabled(!GM_getEnabled());"/>
<command id="gm_toggle_checked" oncommand="GM_setEnabled(!GM_util.getEnabled());"/>
</commandset>

<toolbarpalette id='BrowserToolbarPalette'>
Expand Down
4 changes: 2 additions & 2 deletions content/statusbar.js
Expand Up @@ -21,7 +21,7 @@ window.addEventListener('load', function window_load() {
function GM_statusClicked(aEvent) {
switch (aEvent.button) {
case 0:
GM_setEnabled(!GM_getEnabled());
GM_setEnabled(!GM_util.getEnabled());
break;
case 1:
GM_OpenScriptsMgr();
Expand All @@ -41,7 +41,7 @@ window.GM_statusClicked = GM_statusClicked;
* the mozilla preference that backs it directly.
*/
function refreshStatus() {
if (GM_getEnabled()) {
if (GM_util.getEnabled()) {
statusImageEl.src = "chrome://greasemonkey/skin/icon16.png";
statusImageEl.tooltipText = stringBundle.getString("tooltip.enabled");
} else {
Expand Down
4 changes: 0 additions & 4 deletions content/utils.js
Expand Up @@ -15,10 +15,6 @@ function GM_getConfig() {
return GM_getService().config;
}

function GM_getEnabled() {
return GM_prefRoot.getValue("enabled", true);
}

function GM_setEnabled(enabled) {
GM_prefRoot.setValue("enabled", enabled);
}
Expand Down
7 changes: 7 additions & 0 deletions modules/util/getEnabled.js
@@ -0,0 +1,7 @@
Components.utils.import('resource://greasemonkey/prefmanager.js');

const EXPORTED_SYMBOLS = ['getEnabled'];

function getEnabled() {
return GM_prefRoot.getValue("enabled", true);
}

0 comments on commit d6dd73a

Please sign in to comment.