diff --git a/fancy-settings/manifest.js b/fancy-settings/manifest.js index 94e0127..6369548 100755 --- a/fancy-settings/manifest.js +++ b/fancy-settings/manifest.js @@ -115,6 +115,21 @@ this.manifest = { "type": "description", "text": "
Mostly Harmless uses the reddit API, but sometimes the API will be slow or down. If that happens, Mostly Harmless can display an error after trying to reach the API for a certain amount of time.
This option allows you to change how long Mostly Harmless should try to reach the Reddit API. Longer timeout lengths mean more time waiting for a result from the reddit API. Shorter timeout lengths mean a higher possibility of timing out when reddit may only be slow instead of down." }, + { + "tab": "Privacy", + "group": "Wait for Click", + "name": "waitForClick", + "type": "checkbox", + "label": "Wait for click" + + }, + { + "tab": "Privacy", + "group": "Wait for Click", + "name": "waitForClickDescription", + "type": "description", + "text": "
If this checkbox is selected, Mostly Harmless will not activate unless you click its icon.
" + }, { "tab": "Privacy", "group": "Warning!", diff --git a/js/common.js b/js/common.js index 61cc232..e40b1fb 100644 --- a/js/common.js +++ b/js/common.js @@ -5,7 +5,8 @@ settings = new Store('settings', { 'timeoutLength': 5, 'freshCutoff': 7, 'popupWidth': 640, - 'shamelessPlug': false + 'shamelessPlug': false, + 'waitForClick': false }); cache = new Store('cache'); @@ -752,13 +753,17 @@ function Background() { */ Background.prototype.prepareBrowserAction = function (tabId, info, tab) { if (info.status === 'loading') { - if (cache.get(tab.url) === undefined || cache.get(tab.url).cacheDate - utils.epoch() < -60 * settings.get('cacheTime')) { - console.log(chrome.i18n.getMessage('loading_api')); - console.log(utils.parseURL(tab.url)); - reddit.getInfo(tab.url, tabId); + if (settings.get('waitForClick') === 'true') { + if (cache.get(tab.url) === undefined || cache.get(tab.url).cacheDate - utils.epoch() < -60 * settings.get('cacheTime')) { + console.log(chrome.i18n.getMessage('loading_api')); + console.log(utils.parseURL(tab.url)); + reddit.getInfo(tab.url, tabId); + } else { + console.log(chrome.i18n.getMessage('loading_cache')); + button.setBadgeFor(tab.url, tabId); + } } else { - console.log(chrome.i18n.getMessage('loading_cache')); - button.setBadgeFor(tab.url, tabId); + button.setBadgeIgnore(tabId); } }