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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 if (!(browser.webRequest.ResourceType)) | 60 if (!(browser.webRequest.ResourceType)) |
61 return; | 61 return; |
62 | 62 |
63 for (let type in browser.webRequest.ResourceType) | 63 for (let type in browser.webRequest.ResourceType) |
64 yield resourceTypes.get(browser.webRequest.ResourceType[type]) || "OTHER"; | 64 yield resourceTypes.get(browser.webRequest.ResourceType[type]) || "OTHER"; |
65 | 65 |
66 // WEBRTC gets addressed through a workaround, even if the webRequest API is | 66 // WEBRTC gets addressed through a workaround, even if the webRequest API is |
67 // lacking support to block this kind of a request. | 67 // lacking support to block this kind of a request. |
68 yield "WEBRTC"; | 68 yield "WEBRTC"; |
69 | 69 |
70 // POPUP, CSP and ELEMHIDE filters aren't mapped to resource types. | 70 // ELEMHIDE, POPUP, CSP, and SNIPPET filters aren't mapped to resource types. |
| 71 yield "ELEMHIDE"; |
71 yield "POPUP"; | 72 yield "POPUP"; |
72 yield "ELEMHIDE"; | |
73 yield "CSP"; | 73 yield "CSP"; |
| 74 yield "SNIPPET"; |
74 }()); | 75 }()); |
75 | 76 |
76 function onBeforeRequestAsync(page, url, type, docDomain, | 77 function onBeforeRequestAsync(page, url, type, docDomain, |
77 thirdParty, sitekey, | 78 thirdParty, sitekey, |
78 specificOnly, filter) | 79 specificOnly, filter) |
79 { | 80 { |
80 if (filter) | 81 if (filter) |
81 FilterNotifier.emit("filter.hitCount", filter, 0, 0, page); | 82 FilterNotifier.emit("filter.hitCount", filter, 0, 0, page); |
82 | 83 |
83 if (devtools) | 84 if (devtools) |
84 { | 85 { |
85 devtools.logRequest( | 86 devtools.logRequest( |
86 page, url, type, docDomain, | 87 page, url, type, docDomain, |
87 thirdParty, sitekey, | 88 thirdParty, sitekey, |
88 specificOnly, filter | 89 specificOnly, filter |
89 ); | 90 ); |
90 } | 91 } |
91 } | 92 } |
92 | 93 |
93 ext.webRequest.onBeforeRequest.addListener((url, type, page, frame) => | 94 ext.webRequest.onBeforeRequest.addListener((url, type, page, frame) => |
94 { | 95 { |
95 let docDomain = null; | 96 let docDomain = null; |
96 let sitekey = null; | 97 let sitekey = null; |
97 let specificOnly = false; | 98 let specificOnly = false; |
98 let thirdParty = false; | 99 let thirdParty = false; |
99 let urlString = stringifyURL(url); | 100 let urlString = stringifyURL(url); |
100 | 101 |
101 | |
102 if (frame && page) | 102 if (frame && page) |
103 { | 103 { |
104 if (checkWhitelisted(page, frame)) | 104 if (checkWhitelisted(page, frame)) |
105 return true; | 105 return true; |
106 | 106 |
107 docDomain = extractHostFromFrame(frame); | 107 docDomain = extractHostFromFrame(frame); |
108 sitekey = getKey(page, frame); | 108 sitekey = getKey(page, frame); |
109 thirdParty = isThirdParty(url, docDomain); | 109 thirdParty = isThirdParty(url, docDomain); |
110 specificOnly = !!checkWhitelisted(page, frame, | 110 specificOnly = !!checkWhitelisted(page, frame, |
111 RegExpFilter.typeMap.GENERICBLOCK); | 111 RegExpFilter.typeMap.GENERICBLOCK); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 | 206 |
207 port.on("request.blockedByRTCWrapper", (msg, sender) => | 207 port.on("request.blockedByRTCWrapper", (msg, sender) => |
208 { | 208 { |
209 return ext.webRequest.onBeforeRequest._dispatch( | 209 return ext.webRequest.onBeforeRequest._dispatch( |
210 new URL(msg.url), | 210 new URL(msg.url), |
211 "webrtc", | 211 "webrtc", |
212 sender.page, | 212 sender.page, |
213 sender.frame | 213 sender.frame |
214 ).includes(false); | 214 ).includes(false); |
215 }); | 215 }); |
OLD | NEW |