New message styleReplaceAll
`styleReplaceAll` removes all existing user styles, then applies the styles in the message payload.
This commit is contained in:
parent
99968395d9
commit
c67c9d3f54
11
apply.js
11
apply.js
|
@ -17,6 +17,10 @@ chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
|
||||||
for (var styleId in request.styles) {
|
for (var styleId in request.styles) {
|
||||||
applySections(styleId, request.styles[styleId]);
|
applySections(styleId, request.styles[styleId]);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case "styleReplaceAll":
|
||||||
|
replaceAll(request.styles);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -54,3 +58,10 @@ function applySections(styleId, sections) {
|
||||||
}).join("\n")));
|
}).join("\n")));
|
||||||
document.documentElement.appendChild(styleElement);
|
document.documentElement.appendChild(styleElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function replaceAll(newStyles) {
|
||||||
|
Array.prototype.forEach.call(document.querySelectorAll("STYLE.stylish"), function(style) {
|
||||||
|
style.parentNode.removeChild(style);
|
||||||
|
});
|
||||||
|
applyStyles(newStyles);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user