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 26 matching lines...) Expand all Loading... | |
37 cssOrigin: "user", | 37 cssOrigin: "user", |
38 frameId, | 38 frameId, |
39 matchAboutBlank: true, | 39 matchAboutBlank: true, |
40 runAt: "document_start" | 40 runAt: "document_start" |
41 }); | 41 }); |
42 } | 42 } |
43 | 43 |
44 port.on("elemhide.getSelectors", (msg, sender) => | 44 port.on("elemhide.getSelectors", (msg, sender) => |
45 { | 45 { |
46 let selectors = []; | 46 let selectors = []; |
47 let emulated = []; | 47 let emulatedPatterns = []; |
Manish Jethani
2017/09/26 11:50:18
How about we call this emulationPatterns, similar
Sebastian Noack
2017/09/26 21:50:40
Done.
| |
48 let trace = devtools && devtools.hasPanel(sender.page); | 48 let trace = devtools && devtools.hasPanel(sender.page); |
49 let inject = !userStyleSheetsSupported; | 49 let inject = !userStyleSheetsSupported; |
50 | 50 |
51 if (!checkWhitelisted(sender.page, sender.frame, | 51 if (!checkWhitelisted(sender.page, sender.frame, |
52 RegExpFilter.typeMap.DOCUMENT | | 52 RegExpFilter.typeMap.DOCUMENT | |
53 RegExpFilter.typeMap.ELEMHIDE)) | 53 RegExpFilter.typeMap.ELEMHIDE)) |
54 { | 54 { |
55 let hostname = extractHostFromFrame(sender.frame); | 55 let hostname = extractHostFromFrame(sender.frame); |
Manish Jethani
2017/09/26 11:50:18
I notice that this is a change in behavior, the ol
Sebastian Noack
2017/09/26 21:50:40
You are right, and extractHostFromFrame() should b
| |
56 let specificOnly = checkWhitelisted(sender.page, sender.frame, | 56 let specificOnly = checkWhitelisted(sender.page, sender.frame, |
57 RegExpFilter.typeMap.GENERICHIDE); | 57 RegExpFilter.typeMap.GENERICHIDE); |
58 | 58 |
59 selectors = ElemHide.getSelectorsForDomain( | 59 selectors = ElemHide.getSelectorsForDomain( |
60 hostname, | 60 hostname, |
61 specificOnly ? ElemHide.SPECIFIC_ONLY : ElemHide.ALL_MATCHING | 61 specificOnly ? ElemHide.SPECIFIC_ONLY : ElemHide.ALL_MATCHING |
62 ); | 62 ); |
63 | 63 |
64 for (let filter of ElemHideEmulation.getRulesForDomain(hostname)) | 64 for (let filter of ElemHideEmulation.getRulesForDomain(hostname)) |
65 emulated.push({selector: filter.selector, text: filter.text}); | 65 emulatedPatterns.push({selector: filter.selector, text: filter.text}); |
Manish Jethani
2017/09/26 11:50:18
Just an idea, this could be written idiomatically
Sebastian Noack
2017/09/26 21:50:40
This will result in less efficient code for two re
Manish Jethani
2017/09/26 22:45:18
Fair enough.
I just checked on both Node.js and C
| |
66 } | 66 } |
67 | 67 |
68 if (!inject && selectors.length > 0) | 68 if (!inject && selectors.length > 0) |
69 hideElements(sender.page.id, sender.frame.id, selectors); | 69 hideElements(sender.page.id, sender.frame.id, selectors); |
70 | 70 |
71 let response = {trace, inject, emulated}; | 71 let response = {trace, inject, emulatedPatterns}; |
Manish Jethani
2017/09/26 11:50:18
Maybe not as part of this very change, but we shou
Sebastian Noack
2017/09/26 21:50:40
It seems you misunderstand the concept of emulatio
Manish Jethani
2017/09/26 22:45:18
Yes, it seems I misunderstood. I was thinking we c
| |
72 if (trace || inject) | 72 if (trace || inject) |
73 response.selectors = selectors; | 73 response.selectors = selectors; |
74 | 74 |
75 return response; | 75 return response; |
76 }); | 76 }); |
77 | 77 |
78 port.on("elemhide.injectSelectors", (msg, sender) => | 78 port.on("elemhide.injectSelectors", (msg, sender) => |
79 { | 79 { |
80 hideElements(sender.page.id, sender.frame.id, msg.selectors); | 80 hideElements(sender.page.id, sender.frame.id, msg.selectors); |
81 }); | 81 }); |
LEFT | RIGHT |