diff --git a/apply.js b/apply.js index cba52c65..cd8bf82c 100644 --- a/apply.js +++ b/apply.js @@ -17,6 +17,10 @@ chrome.extension.onMessage.addListener(function(request, sender, sendResponse) { for (var styleId in request.styles) { applySections(styleId, request.styles[styleId]); } + break; + case "styleReplaceAll": + replaceAll(request.styles); + break; } }); @@ -54,3 +58,10 @@ function applySections(styleId, sections) { }).join("\n"))); document.documentElement.appendChild(styleElement); } + +function replaceAll(newStyles) { + Array.prototype.forEach.call(document.querySelectorAll("STYLE.stylish"), function(style) { + style.parentNode.removeChild(style); + }); + applyStyles(newStyles); +}