Left: | ||
Right: |
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-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); | |
Sebastian Noack
2015/07/15 14:30:08
Nit: There should be an empty line below.
saroyanm
2015/07/15 14:36:05
Done.
| |
34 var modules = {}; | 42 var modules = {}; |
35 global.require = function(module) | 43 global.require = function(module) |
36 { | 44 { |
37 return modules[module]; | 45 return modules[module]; |
38 }; | 46 }; |
39 | 47 |
40 modules.utils = { | 48 modules.utils = { |
41 Utils: { | 49 Utils: { |
42 getDocLink: function(link) | 50 getDocLink: function(link) |
43 { | 51 { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 { | 154 { |
147 this.text = text; | 155 this.text = text; |
148 this.disabled = false; | 156 this.disabled = false; |
149 } | 157 } |
150 }; | 158 }; |
151 modules.filterClasses.Filter.fromText = function(text) | 159 modules.filterClasses.Filter.fromText = function(text) |
152 { | 160 { |
153 return new modules.filterClasses.Filter(text); | 161 return new modules.filterClasses.Filter(text); |
154 }; | 162 }; |
155 | 163 |
164 modules.filterValidation = | |
165 { | |
166 parseFilter: function(text) | |
167 { | |
168 | |
169 if (params.filterError) | |
170 return {error: "filter-parsing-error"}; | |
Sebastian Noack
2015/07/15 14:30:08
Nit: This is human readable text. So no need for d
saroyanm
2015/07/15 14:36:05
Done.
| |
171 return {filter: modules.filterClasses.Filter.fromText(text)}; | |
172 }, | |
173 parseFilters: function(text) | |
174 { | |
175 if (params.filterError) | |
176 return {errors: ["filter-parsing-error"]}; | |
177 return {filters: | |
178 text.split("\n").map(modules.filterClasses.Filter.fromText)}; | |
179 } | |
180 }; | |
181 | |
156 modules.synchronizer = { | 182 modules.synchronizer = { |
157 Synchronizer: {} | 183 Synchronizer: {} |
158 }; | 184 }; |
159 | 185 |
160 modules.matcher = { | 186 modules.matcher = { |
161 defaultMatcher: { | 187 defaultMatcher: { |
162 matchesAny: function(url, requestType, docDomain, thirdParty) | 188 matchesAny: function(url, requestType, docDomain, thirdParty) |
163 { | 189 { |
164 var params = {blockedURLs: ""}; | |
165 updateFromURL(params); | |
166 var blocked = params.blockedURLs.split(","); | 190 var blocked = params.blockedURLs.split(","); |
167 if (blocked.indexOf(url) >= 0) | 191 if (blocked.indexOf(url) >= 0) |
168 return new modules.filterClasses.BlockingFilter(); | 192 return new modules.filterClasses.BlockingFilter(); |
169 else | 193 else |
170 return null; | 194 return null; |
171 } | 195 } |
172 } | 196 } |
173 }; | 197 }; |
174 | 198 |
175 var notifierListeners = []; | 199 var notifierListeners = []; |
(...skipping 15 matching lines...) Expand all Loading... | |
191 triggerListeners: function() | 215 triggerListeners: function() |
192 { | 216 { |
193 var args = Array.prototype.slice.apply(arguments); | 217 var args = Array.prototype.slice.apply(arguments); |
194 var listeners = notifierListeners.slice(); | 218 var listeners = notifierListeners.slice(); |
195 for (var i = 0; i < listeners.length; i++) | 219 for (var i = 0; i < listeners.length; i++) |
196 listeners[i].apply(null, args); | 220 listeners[i].apply(null, args); |
197 } | 221 } |
198 } | 222 } |
199 }; | 223 }; |
200 | 224 |
201 modules.info = { | 225 modules.info = { |
saroyanm
2015/07/15 12:06:53
I can't find if we are using it somewhere.
Do we
Thomas Greiner
2015/07/15 12:29:35
Yes, this is being used for the first-run page. Yo
saroyanm
2015/07/15 12:34:58
Got it.
| |
202 platform: "gecko", | 226 platform: "gecko", |
203 platformVersion: "34.0", | 227 platformVersion: "34.0", |
204 application: "firefox", | 228 application: "firefox", |
205 applicationVersion: "34.0", | 229 applicationVersion: "34.0", |
206 addonName: "adblockplus", | 230 addonName: "adblockplus", |
207 addonVersion: "2.6.7" | 231 addonVersion: "2.6.7" |
208 }; | 232 }; |
209 updateFromURL(modules.info); | 233 updateFromURL(modules.info); |
210 | 234 |
211 global.Services = { | 235 global.Services = { |
212 vc: { | 236 vc: { |
213 compare: function(v1, v2) | 237 compare: function(v1, v2) |
214 { | 238 { |
215 return parseFloat(v1) - parseFloat(v2); | 239 return parseFloat(v1) - parseFloat(v2); |
216 } | 240 } |
217 } | 241 } |
218 }; | 242 }; |
219 | 243 |
220 var filters = [ | 244 var filters = [ |
221 "@@||alternate.de^$document", | 245 "@@||alternate.de^$document", |
222 "@@||der.postillion.com^$document", | 246 "@@||der.postillion.com^$document", |
223 "@@||taz.de^$document", | 247 "@@||taz.de^$document", |
224 "@@||amazon.de^$document" | 248 "@@||amazon.de^$document", |
249 "||biglemon.am/bg_poster/banner.jpg", | |
250 "winfuture.de###header_logo_link", | |
251 "###WerbungObenRechts10_GesamtDIV", | |
252 "###WerbungObenRechts8_GesamtDIV", | |
253 "###WerbungObenRechts9_GesamtDIV", | |
254 "###WerbungUntenLinks4_GesamtDIV", | |
255 "###WerbungUntenLinks7_GesamtDIV", | |
256 "###WerbungUntenLinks8_GesamtDIV", | |
257 "###WerbungUntenLinks9_GesamtDIV", | |
258 "###Werbung_Sky", | |
259 "###Werbung_Wide", | |
260 "###__ligatus_placeholder__", | |
261 "###ad-bereich1-08", | |
262 "###ad-bereich1-superbanner", | |
263 "###ad-bereich2-08", | |
264 "###ad-bereich2-skyscrapper" | |
225 ]; | 265 ]; |
226 var knownFilters = filters.map(modules.filterClasses.Filter.fromText); | 266 var knownFilters = filters.map(modules.filterClasses.Filter.fromText); |
227 | 267 |
228 var subscriptions = [ | 268 var subscriptions = [ |
229 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", | 269 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", |
230 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", | 270 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", |
231 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", | 271 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", |
232 "~user~786254" | 272 "~user~786254" |
233 ]; | 273 ]; |
234 var knownSubscriptions = Object.create(null); | 274 var knownSubscriptions = Object.create(null); |
235 for (var subscriptionUrl of subscriptions) | 275 for (var subscriptionUrl of subscriptions) |
236 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti on.fromURL(subscriptionUrl); | 276 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti on.fromURL(subscriptionUrl); |
237 var customSubscription = knownSubscriptions["~user~786254"]; | 277 var customSubscription = knownSubscriptions["~user~786254"]; |
238 | 278 |
239 var issues = {seenDataCorruption: false, filterlistsReinitialized: false}; | 279 global.seenDataCorruption = params.seenDataCorruption; |
240 updateFromURL(issues); | 280 global.filterlistsReinitialized = params.filterlistsReinitialized; |
241 global.seenDataCorruption = issues.seenDataCorruption; | |
242 global.filterlistsReinitialized = issues.filterlistsReinitialized; | |
243 | 281 |
244 var events = {addSubscription: false}; | 282 if (params.addSubscription) |
245 updateFromURL(events); | |
246 if (events.addSubscription) | |
247 { | 283 { |
248 // We don't know how long it will take for the page to fully load | 284 // We don't know how long it will take for the page to fully load |
249 // so we'll post the message after one second | 285 // so we'll post the message after one second |
250 setTimeout(function() | 286 setTimeout(function() |
251 { | 287 { |
252 window.postMessage({ | 288 window.postMessage({ |
253 type: "message", | 289 type: "message", |
254 payload: { | 290 payload: { |
255 title: "Custom subscription", | 291 title: "Custom subscription", |
256 url: "http://example.com/custom.txt", | 292 url: "http://example.com/custom.txt", |
257 type: "add-subscription" | 293 type: "add-subscription" |
258 } | 294 } |
259 }, "*"); | 295 }, "*"); |
260 }, 1000); | 296 }, 1000); |
261 } | 297 } |
262 })(this); | 298 })(this); |
OLD | NEW |