Index: lib/cssInjection.js |
=================================================================== |
--- a/lib/cssInjection.js |
+++ b/lib/cssInjection.js |
@@ -94,31 +94,34 @@ |
browser.tabs.removeCSS(tabId, { |
code: styleSheet, |
cssOrigin: "user", |
frameId, |
matchAboutBlank: true |
}); |
} |
-function updateFrameStyles(tabId, frameId, selectors, groupName) |
+function updateFrameStyles(tabId, frameId, selectors, groupName, appendOnly) |
{ |
- let styleSheet = null; |
+ let styleSheet = ""; |
Manish Jethani
2018/02/27 16:00:22
I changed this to an empty string because it doesn
kzar
2018/02/27 17:25:22
Acknowledged.
|
if (selectors.length > 0) |
styleSheet = createStyleSheet(selectors); |
let frame = ext.getFrame(tabId, frameId); |
if (!frame) |
return false; |
if (!frame.injectedStyleSheets) |
frame.injectedStyleSheets = new Map(); |
let oldStyleSheet = frame.injectedStyleSheets.get(groupName); |
+ if (appendOnly && oldStyleSheet) |
+ styleSheet = oldStyleSheet + styleSheet; |
+ |
// Ideally we would compare the old and new style sheets and skip this code |
// if they're the same, but the old style sheet can be a leftover from a |
// previous instance of the frame. We must add the new style sheet |
// regardless. |
// Add the new style sheet first to keep previously hidden elements from |
// reappearing momentarily. |
if (styleSheet && !addStyleSheet(tabId, frameId, styleSheet)) |
@@ -176,10 +179,10 @@ |
response.inlineEmulated = true; |
return response; |
}); |
port.on("elemhide.injectSelectors", (message, sender) => |
{ |
updateFrameStyles(sender.page.id, sender.frame.id, message.selectors, |
- message.groupName); |
+ message.groupName, message.appendOnly); |
}); |