Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 ext.devtools = { | 18 "use strict"; |
19 connect: function() | |
20 { | |
21 return { | |
22 postMessage: function() {}, | |
23 | 19 |
24 onMessage: { | 20 (function(global) |
25 addListener: function(listener) | 21 { |
Wladimir Palant
2015/01/10 08:33:29
Quite frankly, I don't like the idea of having a d
Sebastian Noack
2015/01/10 08:53:45
Yes, it will be fairly complicated. Ports are very
Thomas Greiner
2015/01/12 10:37:54
Right, the existing abstraction layer would probab
Wladimir Palant
2015/01/13 07:28:04
I see, that's making things too complicated indeed
Sebastian Noack
2015/02/04 14:17:29
As discussed some weeks ago, we can actually use r
| |
26 { | 22 if (!global.ext) |
27 // blocked request | 23 global.ext = {}; |
28 listener({ | |
29 type: "add-record", | |
30 request: { | |
31 url: "http://adserver.example.com/ad_banner.png", | |
32 type: "IMAGE", | |
33 docDomain: "example.com" | |
34 }, | |
35 filter: { | |
36 text: "/ad_banner*$domain=example.com", | |
37 whitelisted: false, | |
38 userDefined: false, | |
39 subscription: "EasyList" | |
40 } | |
41 }); | |
42 | 24 |
43 // whiletisted request | 25 global.ext.devtools = { |
44 listener({ | 26 panels: { |
45 type: "add-record", | 27 openResource: function() {} |
46 request: { | 28 }, |
47 url: "http://example.com/looks_like_an_ad_but_isnt_one.html", | |
48 type: "SUBDOCUMENT", | |
49 docDomain: "example.com" | |
50 }, | |
51 filter: { | |
52 text: "@@||example.com/looks_like_an_ad_but_isnt_one.html", | |
53 whitelisted: true, | |
54 userDefined: false, | |
55 subscription: "EasyList" | |
56 } | |
57 }); | |
58 | 29 |
59 // request with long URL and no filter matches | 30 inspectedWindow: { |
60 listener({ | 31 reload: function() {} |
61 type: "add-record", | 32 } |
62 request: { | 33 }; |
63 url: "https://this.url.has.a.long.domain/and_a_long_path_maybe_not _long_enough_so_i_keep_typing?there=are&a=couple&of=parameters&as=well&and=even& some=more", | |
64 type: "XMLHTTPREQUEST", | |
65 docDomain: "example.com" | |
66 }, | |
67 filter: null | |
68 }); | |
69 | 34 |
70 // matching element hiding filter | 35 global.ext.backgroundPage._sendRawMessage({type: "devtools"}); |
71 listener({ | 36 })(this); |
72 type: "add-record", | |
73 request: { | |
74 type: "ELEMHIDE", | |
75 docDomain: "example.com" | |
76 }, | |
77 filter: { | |
78 text: "example.com##.ad_banner", | |
79 whitelisted: false, | |
80 userDefined: false, | |
81 subscription: "EasyList" | |
82 } | |
83 }); | |
84 | |
85 // user-defined filter | |
86 listener({ | |
87 type: "add-record", | |
88 request: { | |
89 url: "http://example.com/some-annoying-popup", | |
90 type: "POPUP", | |
91 docDomain: "example.com" | |
92 }, | |
93 filter: { | |
94 text: "||example.com/some-annoying-popup$popup", | |
95 whitelisted: false, | |
96 userDefined: true, | |
97 subscription: null | |
98 } | |
99 }); | |
Wladimir Palant
2015/01/10 08:33:29
I'd rather have proper message exchange simulated,
Sebastian Noack
2015/01/10 08:53:45
This would makes things significantly more complex
Thomas Greiner
2015/01/12 10:37:54
More complex because we're using two different met
Sebastian Noack
2015/01/12 11:55:07
What Wladimir is suggesting is to inject an iframe
Wladimir Palant
2015/01/13 07:28:04
Yes, this is just us testing that thing properly a
Sebastian Noack
2015/02/04 14:17:29
Yep, done, see above.
| |
100 | |
101 } | |
102 } | |
103 }; | |
104 }, | |
105 | |
106 panels: { | |
107 openResource: function() {} | |
108 }, | |
109 | |
110 inspectedWindow: { | |
111 reload: function() {} | |
112 } | |
113 } | |
114 | |
LEFT | RIGHT |