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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 function updateContextMenu(page, filter) | 177 function updateContextMenu(page, filter) |
178 { | 178 { |
179 page.contextMenus.remove(contextMenuItem); | 179 page.contextMenus.remove(contextMenuItem); |
180 | 180 |
181 if (typeof filter == "undefined") | 181 if (typeof filter == "undefined") |
182 filter = checkWhitelisted(page); | 182 filter = checkWhitelisted(page); |
183 if (!filter && Prefs.shouldShowBlockElementMenu && readyPages.has(page)) | 183 if (!filter && Prefs.shouldShowBlockElementMenu && readyPages.has(page)) |
184 page.contextMenus.create(contextMenuItem); | 184 page.contextMenus.create(contextMenuItem); |
185 } | 185 } |
186 | 186 |
187 FilterNotifier.on("page.WhitelistingStateRevalidate", updateContextMenu); | 187 if (chrome.contextMenus) |
| 188 { |
| 189 FilterNotifier.on("page.WhitelistingStateRevalidate", updateContextMenu); |
188 | 190 |
189 Prefs.on("shouldShowBlockElementMenu", () => | 191 Prefs.on("shouldShowBlockElementMenu", () => |
190 { | |
191 ext.pages.query({}, pages => | |
192 { | 192 { |
193 for (let page of pages) | 193 ext.pages.query({}, pages => |
194 updateContextMenu(page); | 194 { |
| 195 for (let page of pages) |
| 196 updateContextMenu(page); |
| 197 }); |
195 }); | 198 }); |
196 }); | 199 } |
197 | 200 |
198 port.on("composer.ready", (message, sender) => | 201 port.on("composer.ready", (message, sender) => |
199 { | 202 { |
200 readyPages.set(sender.page, null); | 203 readyPages.set(sender.page, null); |
201 updateContextMenu(sender.page); | 204 |
| 205 if (chrome.contextMenus) |
| 206 updateContextMenu(sender.page); |
202 }); | 207 }); |
203 | 208 |
204 port.on("composer.openDialog", (message, sender) => | 209 port.on("composer.openDialog", (message, sender) => |
205 { | 210 { |
206 return new Promise(resolve => | 211 return new Promise(resolve => |
207 { | 212 { |
208 ext.windows.create({ | 213 ext.windows.create({ |
209 url: ext.getURL("composer.html"), | 214 url: ext.getURL("composer.html"), |
210 left: 50, | 215 left: 50, |
211 top: 50, | 216 top: 50, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 256 |
252 port.on("composer.quoteCSS", (message, sender) => | 257 port.on("composer.quoteCSS", (message, sender) => |
253 { | 258 { |
254 return quoteCSS(message.CSS); | 259 return quoteCSS(message.CSS); |
255 }); | 260 }); |
256 | 261 |
257 ext.pages.onLoading.addListener(page => | 262 ext.pages.onLoading.addListener(page => |
258 { | 263 { |
259 page.sendMessage({type: "composer.content.finished"}); | 264 page.sendMessage({type: "composer.content.finished"}); |
260 }); | 265 }); |
OLD | NEW |