| 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 = ""; |
| 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); |
| }); |