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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 13 matching lines...) Expand all Loading... | |
24 var params = window.location.search.substr(1).split("&"); | 24 var params = window.location.search.substr(1).split("&"); |
25 for (var i = 0; i < params.length; i++) | 25 for (var i = 0; i < params.length; i++) |
26 { | 26 { |
27 var parts = params[i].split("=", 2); | 27 var parts = params[i].split("=", 2); |
28 if (parts.length == 2 && parts[0] in data) | 28 if (parts.length == 2 && parts[0] in data) |
29 data[parts[0]] = decodeURIComponent(parts[1]); | 29 data[parts[0]] = decodeURIComponent(parts[1]); |
30 } | 30 } |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 var params = { | |
35 blockedURLs: "", | |
36 seenDataCorruption: false, | |
37 filterlistsReinitialized: false, | |
38 addSubscription: false, | |
39 filterError: false | |
40 }; | |
41 updateFromURL(params); | |
42 | |
34 var modules = {}; | 43 var modules = {}; |
35 global.require = function(module) | 44 global.require = function(module) |
36 { | 45 { |
37 return modules[module]; | 46 return modules[module]; |
38 }; | 47 }; |
39 | 48 |
40 modules.utils = { | 49 modules.utils = { |
41 Utils: { | 50 Utils: { |
42 getDocLink: function(link) | 51 getDocLink: function(link) |
43 { | 52 { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 }; | 159 }; |
151 modules.filterClasses.Filter.fromText = function(text) | 160 modules.filterClasses.Filter.fromText = function(text) |
152 { | 161 { |
153 return new modules.filterClasses.Filter(text); | 162 return new modules.filterClasses.Filter(text); |
154 }; | 163 }; |
155 | 164 |
156 modules.filterValidation = | 165 modules.filterValidation = |
157 { | 166 { |
158 parseFilter: function(text) | 167 parseFilter: function(text) |
159 { | 168 { |
160 var filterError = {filterError: false}; | 169 |
161 updateFromURL(filterError); | 170 if (params.filterError) |
Thomas Greiner
2015/07/15 08:32:35
Add this parameter to the README.
saroyanm
2015/07/15 10:47:08
Done.
| |
162 if (filterError) | 171 return {error: "Invalid filter"}; |
Sebastian Noack
2015/07/15 09:00:44
This will always be true. It should be |filterErro
saroyanm
2015/07/15 10:47:11
Done.
| |
163 return {error: "Filter-parsing-error-occurred"}; | |
Thomas Greiner
2015/07/15 08:32:36
I'd suggest to use all lower-case for consistency
saroyanm
2015/07/15 10:47:08
Done.
| |
164 return {filter: modules.filterClasses.Filter.fromText(text)}; | 172 return {filter: modules.filterClasses.Filter.fromText(text)}; |
165 }, | 173 }, |
166 parseFilters: function(text) | 174 parseFilters: function(text) |
167 { | 175 { |
168 return {filters: text.split("\n").map(modules.filterClasses.Filter.fromTex t)}; | 176 if (params.filterError) |
Thomas Greiner
2015/07/15 08:32:35
This line exceeds the 80 characters limit.
Sebastian Noack
2015/07/15 09:00:44
You don't consider the filter filterError URL para
saroyanm
2015/07/15 10:47:09
Done.
saroyanm
2015/07/15 10:47:11
Done.
| |
177 return {errors: ["Invalid filter"]}; | |
178 return {filters: | |
179 text.split("\n").map(modules.filterClasses.Filter.fromText)}; | |
169 } | 180 } |
170 }; | 181 }; |
171 | 182 |
172 modules.synchronizer = { | 183 modules.synchronizer = { |
173 Synchronizer: {} | 184 Synchronizer: {} |
174 }; | 185 }; |
175 | 186 |
176 modules.matcher = { | 187 modules.matcher = { |
177 defaultMatcher: { | 188 defaultMatcher: { |
178 matchesAny: function(url, requestType, docDomain, thirdParty) | 189 matchesAny: function(url, requestType, docDomain, thirdParty) |
179 { | 190 { |
180 var params = {blockedURLs: ""}; | |
181 updateFromURL(params); | |
182 var blocked = params.blockedURLs.split(","); | 191 var blocked = params.blockedURLs.split(","); |
183 if (blocked.indexOf(url) >= 0) | 192 if (blocked.indexOf(url) >= 0) |
184 return new modules.filterClasses.BlockingFilter(); | 193 return new modules.filterClasses.BlockingFilter(); |
185 else | 194 else |
186 return null; | 195 return null; |
187 } | 196 } |
188 } | 197 } |
189 }; | 198 }; |
190 | 199 |
191 var notifierListeners = []; | 200 var notifierListeners = []; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", | 270 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", |
262 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", | 271 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", |
263 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", | 272 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", |
264 "~user~786254" | 273 "~user~786254" |
265 ]; | 274 ]; |
266 var knownSubscriptions = Object.create(null); | 275 var knownSubscriptions = Object.create(null); |
267 for (var subscriptionUrl of subscriptions) | 276 for (var subscriptionUrl of subscriptions) |
268 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti on.fromURL(subscriptionUrl); | 277 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti on.fromURL(subscriptionUrl); |
269 var customSubscription = knownSubscriptions["~user~786254"]; | 278 var customSubscription = knownSubscriptions["~user~786254"]; |
270 | 279 |
271 var issues = {seenDataCorruption: false, filterlistsReinitialized: false}; | 280 global.seenDataCorruption = params.seenDataCorruption; |
272 updateFromURL(issues); | 281 global.filterlistsReinitialized = params.filterlistsReinitialized; |
273 global.seenDataCorruption = issues.seenDataCorruption; | |
274 global.filterlistsReinitialized = issues.filterlistsReinitialized; | |
275 | 282 |
276 var events = {addSubscription: false}; | 283 if (params.addSubscription) |
277 updateFromURL(events); | |
278 if (events.addSubscription) | |
279 { | 284 { |
280 // We don't know how long it will take for the page to fully load | 285 // We don't know how long it will take for the page to fully load |
281 // so we'll post the message after one second | 286 // so we'll post the message after one second |
282 setTimeout(function() | 287 setTimeout(function() |
283 { | 288 { |
284 window.postMessage({ | 289 window.postMessage({ |
285 type: "message", | 290 type: "message", |
286 payload: { | 291 payload: { |
287 title: "Custom subscription", | 292 title: "Custom subscription", |
288 url: "http://example.com/custom.txt", | 293 url: "http://example.com/custom.txt", |
289 type: "add-subscription" | 294 type: "add-subscription" |
290 } | 295 } |
291 }, "*"); | 296 }, "*"); |
292 }, 1000); | 297 }, 1000); |
293 } | 298 } |
294 })(this); | 299 })(this); |
LEFT | RIGHT |