diff --git a/manage.html b/manage.html index 79c044db..feed85d8 100644 --- a/manage.html +++ b/manage.html @@ -153,6 +153,12 @@ + + diff --git a/manage.js b/manage.js index 35f8e9af..884a9b95 100644 --- a/manage.js +++ b/manage.js @@ -44,13 +44,8 @@ function createStyleElement(style) { var styleName = e.querySelector(".style-name"); styleName.appendChild(document.createTextNode(style.name)); if (style.url) { - var homepage = document.createElement("a"); + var homepage = template.styleHomepage.cloneNode(true) homepage.setAttribute("href", style.url); - homepage.setAttribute("target", "_blank"); - var homepageImg = document.createElement("img"); - homepageImg.src = "world_go.png"; - homepageImg.alt = "*"; - homepage.appendChild(homepageImg); styleName.appendChild(document.createTextNode(" " )); styleName.appendChild(homepage); } diff --git a/storage.js b/storage.js index 5cd345ee..14f9c1b3 100644 --- a/storage.js +++ b/storage.js @@ -36,38 +36,45 @@ function getStyles(options, callback) { }, null); } -function filterStyles(unfilteredStyles, options) { +function filterStyles(styles, options) { var enabled = fixBoolean(options.enabled); var url = "url" in options ? options.url : null; var id = "id" in options ? Number(options.id) : null; var matchUrl = "matchUrl" in options ? options.matchUrl : null; - // Return as a hash from style to applicable sections? Can only be used with matchUrl. - var asHash = "asHash" in options ? options.asHash : false; - var styles = asHash ? {disableAll: prefs.get("disableAll", false)} : []; - unfilteredStyles.forEach(function(style) { - if (enabled != null && style.enabled != enabled) { - return; - } - if (url != null && style.url != url) { - return; - } - if (id != null && style.id != id) { - return; - } - if (matchUrl != null) { - var applicableSections = getApplicableSections(style, matchUrl); - if (applicableSections.length > 0) { - if (asHash) { - styles[style.id] = applicableSections; - } else { - styles.push(style) + if (enabled != null) { + styles = styles.filter(function(style) { + return style.enabled != enabled; + }); + } + if (url != null) { + styles = styles.filter(function(style) { + return style.url != url; + }); + } + if (id != null) { + styles = styles.filter(function(style) { + return style.id != id; + }); + } + if (matchUrl != null) { + // Return as a hash from style to applicable sections? Can only be used with matchUrl. + var asHash = "asHash" in options ? options.asHash : false; + if (asHash) { + var h = {disableAll: prefs.get("disableAll", false)}; + styles.forEach(function(style) { + var applicableSections = getApplicableSections(style, matchUrl); + if (applicableSections.length > 0) { + h[style.id] = applicableSections; } - } - } else { - styles.push(style); + }); + return h; } - }); + styles = styles.filter(function(style) { + var applicableSections = getApplicableSections(style, matchUrl); + return applicableSections.length > 0; + }); + } return styles; }