diff --git a/background.js b/background.js index 80e6ffe3..1f204e63 100644 --- a/background.js +++ b/background.js @@ -1,7 +1,13 @@ // This happens right away, sometimes so fast that the content script isn't even ready. That's // why the content script also asks for this stuff. chrome.webNavigation.onCommitted.addListener(function(data) { - if (data.frameId !== 0) return; + // Until Chrome 41, we can't target a frame with a message + // (https://developer.chrome.com/extensions/tabs#method-sendMessage) + // so a style affecting a page with an iframe will affect the main page as well. + // Skip doing this for frames for now, which can result in flicker. + if (data.frameId != 0) { + return; + } getStyles({matchUrl: data.url, enabled: true, asHash: true}, function(styleHash) { chrome.tabs.sendMessage(data.tabId, {method: "styleApply", styles: styleHash}); // Don't show the badge for frames @@ -150,23 +156,23 @@ function sectionAppliesToUrl(section, url) { return false; } if (!section.urls && !section.domains && !section.urlPrefixes && !section.regexps) { - console.log(section.id + " is global"); + //console.log(section.id + " is global"); return true; } if (section.urls && section.urls.indexOf(url) != -1) { - console.log(section.id + " applies to " + url + " due to URL rules"); + //console.log(section.id + " applies to " + url + " due to URL rules"); return true; } if (section.urlPrefixes && section.urlPrefixes.some(function(prefix) { return url.indexOf(prefix) == 0; })) { - console.log(section.id + " applies to " + url + " due to URL prefix rules"); + //console.log(section.id + " applies to " + url + " due to URL prefix rules"); return true; } if (section.domains && getDomains(url).some(function(domain) { return section.domains.indexOf(domain) != -1; })) { - console.log(section.id + " applies due to " + url + " due to domain rules"); + //console.log(section.id + " applies due to " + url + " due to domain rules"); return true; } if (section.regexps && section.regexps.some(function(regexp) { @@ -185,10 +191,10 @@ function sectionAppliesToUrl(section, url) { } return (re).test(url); })) { - console.log(section.id + " applies to " + url + " due to regexp rules"); + //console.log(section.id + " applies to " + url + " due to regexp rules"); return true; } - console.log(section.id + " does not apply due to " + url); + //console.log(section.id + " does not apply due to " + url); return false; } diff --git a/edit.js b/edit.js index d6324f1c..a2ea306f 100644 --- a/edit.js +++ b/edit.js @@ -19,7 +19,7 @@ function setupCodeMirror(textarea) { mode: 'css', lineNumbers: true, lineWrapping: true, - smartIndent: localStorage["smart-indent"] == null || localStorage["smart-indent"] == "true" + smartIndent: (typeof localStorage["smart-indent"] == "undefined") || localStorage["smart-indent"] == "true" }); editors.push(cm); } @@ -125,7 +125,7 @@ window.addEventListener("load", init, false); function init() { tE("sections-help", "helpAlt", "alt"); - loadPrefs(["smart-indent"]); + loadPrefs({"smart-indent": "true"}); var params = getParams(); if (!params.id) { // match should be 2 - one for the whole thing, one for the parentheses // This is an add diff --git a/manage.js b/manage.js index 3d34c009..8551e408 100644 --- a/manage.js +++ b/manage.js @@ -15,7 +15,7 @@ function showStyles(styles) { styles.map(createStyleElement).forEach(function(e) { installed.appendChild(e); }); - loadPrefs(["show-badge"]); + loadPrefs({"show-badge": "true"}); } function createStyleElement(style) { diff --git a/popup.html b/popup.html index 062a8fcd..a66d0de4 100644 --- a/popup.html +++ b/popup.html @@ -35,6 +35,10 @@ #unavailable { display: none; } + /* Never shown, but can be enabled with a style */ + .enable, .disable { + display: none; + } diff --git a/popup.js b/popup.js index e278788e..dd182e7a 100644 --- a/popup.js +++ b/popup.js @@ -1,5 +1,5 @@ var styleTemplate = document.createElement("div"); -styleTemplate.innerHTML = "
"; +styleTemplate.innerHTML = "