| Index: lib/contentFiltering.js |
| =================================================================== |
| --- a/lib/contentFiltering.js |
| +++ b/lib/contentFiltering.js |
| @@ -132,20 +132,21 @@ |
| 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(); |
| + if (!frame.injectedSelectors) |
| + frame.injectedSelectors = new Map(); |
| - let oldStyleSheet = frame.injectedStyleSheets.get(groupName); |
| + let oldSelectors = frame.injectedSelectors.get(groupName); |
| + let oldStyleSheet = oldSelectors ? createStyleSheet(oldSelectors) : null; |
| 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. |
| @@ -156,17 +157,18 @@ |
| return false; |
| // Sometimes the old and new style sheets can be exactly the same. In such a |
| // case, do not remove the "old" style sheet, because it is in fact the new |
| // style sheet now. |
| if (oldStyleSheet && oldStyleSheet != styleSheet) |
| removeStyleSheet(tabId, frameId, oldStyleSheet); |
| - frame.injectedStyleSheets.set(groupName, styleSheet); |
| + if (selectors.length > 0) |
| + frame.injectedSelectors.set(groupName, selectors); |
| return true; |
| } |
| function getExecutableCode(script) |
| { |
| let code = executableCode.get(script); |
| if (code) |
| return code; |