Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 "use strict"; | 18 "use strict"; |
19 | 19 |
20 let panelWindow = null; | 20 let panelWindow = null; |
21 | 21 |
22 chrome.runtime.sendMessage( | 22 // Versions of Firefox before 54 do not support the devtools.panels API; on |
23 { | 23 // these platforms, even when the option is enabled, we cannot show the |
24 type: "prefs.get", | 24 // devtools panel. |
25 key: "show_devtools_panel" | 25 if ("panels" in chrome.devtools) |
26 }, | 26 { |
27 enabled => | 27 chrome.runtime.sendMessage( |
28 { | |
29 if (enabled && "panels" in chrome.devtools) | |
Sebastian Noack
2017/09/08 20:29:06
There should be a comment mentioning to the effect
Manish Jethani
2017/09/08 21:19:54
Done.
| |
30 { | 28 { |
31 chrome.devtools.panels.create( | 29 type: "prefs.get", |
32 "Adblock Plus", | 30 key: "show_devtools_panel" |
33 "icons/detailed/abp-48.png", | 31 }, |
34 "devtools-panel.html", | 32 enabled => |
35 panel => | 33 { |
36 { | 34 if (enabled) |
37 panel.onShown.addListener(window => | 35 { |
36 chrome.devtools.panels.create( | |
37 "Adblock Plus", | |
38 "icons/detailed/abp-48.png", | |
39 "devtools-panel.html", | |
40 panel => | |
38 { | 41 { |
39 panelWindow = window; | 42 panel.onShown.addListener(window => |
40 }); | 43 { |
44 panelWindow = window; | |
45 }); | |
41 | 46 |
42 panel.onHidden.addListener(window => | 47 panel.onHidden.addListener(window => |
43 { | 48 { |
44 panelWindow = null; | 49 panelWindow = null; |
45 }); | 50 }); |
46 | 51 |
47 if (panel.onSearch) | 52 if (panel.onSearch) |
48 { | |
49 panel.onSearch.addListener((eventName, queryString) => | |
50 { | 53 { |
51 if (panelWindow) | 54 panel.onSearch.addListener((eventName, queryString) => |
52 panelWindow.postMessage({type: eventName, queryString}, "*"); | 55 { |
53 }); | 56 if (panelWindow) |
57 panelWindow.postMessage({type: eventName, queryString}, "*"); | |
58 }); | |
59 } | |
54 } | 60 } |
55 } | 61 ); |
56 ); | 62 } |
57 } | 63 } |
58 } | 64 ); |
59 ); | 65 } |
LEFT | RIGHT |