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 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 { | 96 { |
97 window.clearTimeout(activateClickHide.timeout); | 97 window.clearTimeout(activateClickHide.timeout); |
98 activateClickHide.timeout = null; | 98 activateClickHide.timeout = null; |
99 } | 99 } |
100 document.body.classList.remove("clickhide-active"); | 100 document.body.classList.remove("clickhide-active"); |
101 browser.tabs.sendMessage(tab.id, {type: "composer.content.finished"}); | 101 browser.tabs.sendMessage(tab.id, {type: "composer.content.finished"}); |
102 } | 102 } |
103 | 103 |
104 function reportIssue() | 104 function reportIssue() |
105 { | 105 { |
106 // capture the current visible tab | 106 // the issue reporter needs to take a screenshot of the |
107 browser.tabs.captureVisibleTab( | 107 // currently active tab, which is why active is explicitly |
Sebastian Noack
2018/05/22 15:28:59
I suppose we also have to add a new permission for
a.giammarchi
2018/05/22 15:55:31
AFAIK there's no need for extra permission, tabs w
Sebastian Noack
2018/05/22 16:01:10
Oh cool, never mind then.
| |
108 null, | 108 // set as false, in case option defaults will ever change. |
109 {format: "png"}, | 109 browser.tabs.create({ |
110 (screenshot) => | 110 active: false, |
111 { | 111 url: browser.runtime.getURL("/issue-reporter.html?" + tab.id) |
112 // setup a listener to provide once tab url | 112 }).then(() => |
113 // and base64 screenshot data once asked | 113 { |
114 browser.runtime.onMessage.addListener( | 114 window.close(); |
115 function onMessage(event) | 115 }); |
116 { | |
117 if (event.type === "issue-reporter") | |
118 { | |
119 browser.runtime.onMessage.removeListener(onMessage); | |
120 return Promise.resolve({ | |
121 url: tab.url, | |
122 screenshot | |
Sebastian Noack
2018/05/22 15:28:59
Nit: It appears that this literal would fit on one
a.giammarchi
2018/05/22 16:14:09
Done.
| |
123 }); | |
124 } | |
125 } | |
126 ); | |
127 | |
128 // create an active/selected issue reporter tab | |
129 browser.tabs.create({ | |
130 selected: true, | |
Sebastian Noack
2018/05/22 15:28:59
The "selected" property is deprecated, use "active
a.giammarchi
2018/05/22 15:55:31
Should I use both to be sure it works? I think I u
Sebastian Noack
2018/05/22 16:01:10
That is not necessary, "active" was introduced lon
a.giammarchi
2018/05/22 16:14:08
Done.
| |
131 url: browser.runtime.getURL("/issue-reporter.html?" + tab.id) | |
132 }); | |
133 } | |
134 ); | |
135 } | 116 } |
136 | 117 |
137 function toggleCollapse(event) | 118 function toggleCollapse(event) |
138 { | 119 { |
139 let collapser = event.currentTarget; | 120 let collapser = event.currentTarget; |
140 let collapsible = document.getElementById(collapser.dataset.collapsible); | 121 let collapsible = document.getElementById(collapser.dataset.collapsible); |
141 collapsible.classList.toggle("collapsed"); | 122 collapsible.classList.toggle("collapsed"); |
142 togglePref(collapser.dataset.option); | 123 togglePref(collapser.dataset.option); |
143 } | 124 } |
144 | 125 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 { | 336 { |
356 if (event.target.id == "notification-optout") | 337 if (event.target.id == "notification-optout") |
357 setPref("notifications_ignoredcategories", true); | 338 setPref("notifications_ignoredcategories", true); |
358 | 339 |
359 notificationElement.hidden = true; | 340 notificationElement.hidden = true; |
360 browser.runtime.sendMessage({type: "notifications.clicked"}); | 341 browser.runtime.sendMessage({type: "notifications.clicked"}); |
361 } | 342 } |
362 }, true); | 343 }, true); |
363 }); | 344 }); |
364 }); | 345 }); |
LEFT | RIGHT |