Popup: actually show newly installed styles

fixup 5b0d8fb
This commit is contained in:
tophf 2015-05-08 03:48:09 +03:00
parent 0b821463c8
commit 60381603db

View File

@ -193,11 +193,15 @@ function handleUpdate(style) {
var styleElement = installed.querySelector("[style-id='" + style.id + "']");
if (styleElement) {
installed.replaceChild(createStyleElement(style), styleElement);
} else if (chrome.extension.getBackgroundPage().getApplicableSections(style, location.href).length) {
} else {
chrome.tabs.query({currentWindow: true, active: true}, function(tabs) {
if (tabs.length && chrome.extension.getBackgroundPage().getApplicableSections(style, tabs[0].url).length) {
// a new style for the current url is installed
document.getElementById("unavailable").style.display = "none";
installed.appendChild(createStyleElement(style));
}
});
}
}
function handleDelete(id) {
@ -214,6 +218,7 @@ function handleDisableAll(disableAll) {
chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
if (request.method == "updatePopup") {
switch (request.reason) {
case "styleAdded":
case "styleUpdated":
handleUpdate(request.style);
break;