OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 }); | 99 }); |
100 } | 100 } |
101 | 101 |
102 function updateFrameStyles(tabId, frameId, selectors, groupName) | 102 function updateFrameStyles(tabId, frameId, selectors, groupName) |
103 { | 103 { |
104 let styleSheet = null; | 104 let styleSheet = null; |
105 if (selectors.length > 0) | 105 if (selectors.length > 0) |
106 styleSheet = createStyleSheet(selectors); | 106 styleSheet = createStyleSheet(selectors); |
107 | 107 |
108 let frame = ext.getFrame(tabId, frameId); | 108 let frame = ext.getFrame(tabId, frameId); |
| 109 if (!frame) |
| 110 return false; |
| 111 |
109 if (!frame.injectedStyleSheets) | 112 if (!frame.injectedStyleSheets) |
110 frame.injectedStyleSheets = new Map(); | 113 frame.injectedStyleSheets = new Map(); |
111 | 114 |
112 let oldStyleSheet = frame.injectedStyleSheets.get(groupName); | 115 let oldStyleSheet = frame.injectedStyleSheets.get(groupName); |
113 | 116 |
114 // Ideally we would compare the old and new style sheets and skip this code | 117 // Ideally we would compare the old and new style sheets and skip this code |
115 // if they're the same, but the old style sheet can be a leftover from a | 118 // if they're the same, but the old style sheet can be a leftover from a |
116 // previous instance of the frame. We must add the new style sheet | 119 // previous instance of the frame. We must add the new style sheet |
117 // regardless. | 120 // regardless. |
118 | 121 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 response.inlineEmulated = true; | 176 response.inlineEmulated = true; |
174 | 177 |
175 return response; | 178 return response; |
176 }); | 179 }); |
177 | 180 |
178 port.on("elemhide.injectSelectors", (message, sender) => | 181 port.on("elemhide.injectSelectors", (message, sender) => |
179 { | 182 { |
180 updateFrameStyles(sender.page.id, sender.frame.id, message.selectors, | 183 updateFrameStyles(sender.page.id, sender.frame.id, message.selectors, |
181 message.groupName); | 184 message.groupName); |
182 }); | 185 }); |
OLD | NEW |