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); |
| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 { | 155 { |
147 this.text = text; | 156 this.text = text; |
148 this.disabled = false; | 157 this.disabled = false; |
149 } | 158 } |
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 |
| 165 modules.filterValidation = |
| 166 { |
| 167 parseFilter: function(text) |
| 168 { |
| 169 |
| 170 if (params.filterError) |
| 171 return {error: "Invalid filter"}; |
| 172 return {filter: modules.filterClasses.Filter.fromText(text)}; |
| 173 }, |
| 174 parseFilters: function(text) |
| 175 { |
| 176 if (params.filterError) |
| 177 return {errors: ["Invalid filter"]}; |
| 178 return {filters: |
| 179 text.split("\n").map(modules.filterClasses.Filter.fromText)}; |
| 180 } |
| 181 }; |
| 182 |
156 modules.synchronizer = { | 183 modules.synchronizer = { |
157 Synchronizer: {} | 184 Synchronizer: {} |
158 }; | 185 }; |
159 | 186 |
160 modules.matcher = { | 187 modules.matcher = { |
161 defaultMatcher: { | 188 defaultMatcher: { |
162 matchesAny: function(url, requestType, docDomain, thirdParty) | 189 matchesAny: function(url, requestType, docDomain, thirdParty) |
163 { | 190 { |
164 var params = {blockedURLs: ""}; | |
165 updateFromURL(params); | |
166 var blocked = params.blockedURLs.split(","); | 191 var blocked = params.blockedURLs.split(","); |
167 if (blocked.indexOf(url) >= 0) | 192 if (blocked.indexOf(url) >= 0) |
168 return new modules.filterClasses.BlockingFilter(); | 193 return new modules.filterClasses.BlockingFilter(); |
169 else | 194 else |
170 return null; | 195 return null; |
171 } | 196 } |
172 } | 197 } |
173 }; | 198 }; |
174 | 199 |
175 var notifierListeners = []; | 200 var notifierListeners = []; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 { | 239 { |
215 return parseFloat(v1) - parseFloat(v2); | 240 return parseFloat(v1) - parseFloat(v2); |
216 } | 241 } |
217 } | 242 } |
218 }; | 243 }; |
219 | 244 |
220 var filters = [ | 245 var filters = [ |
221 "@@||alternate.de^$document", | 246 "@@||alternate.de^$document", |
222 "@@||der.postillion.com^$document", | 247 "@@||der.postillion.com^$document", |
223 "@@||taz.de^$document", | 248 "@@||taz.de^$document", |
224 "@@||amazon.de^$document" | 249 "@@||amazon.de^$document", |
| 250 "||biglemon.am/bg_poster/banner.jpg", |
| 251 "winfuture.de###header_logo_link", |
| 252 "###WerbungObenRechts10_GesamtDIV", |
| 253 "###WerbungObenRechts8_GesamtDIV", |
| 254 "###WerbungObenRechts9_GesamtDIV", |
| 255 "###WerbungUntenLinks4_GesamtDIV", |
| 256 "###WerbungUntenLinks7_GesamtDIV", |
| 257 "###WerbungUntenLinks8_GesamtDIV", |
| 258 "###WerbungUntenLinks9_GesamtDIV", |
| 259 "###Werbung_Sky", |
| 260 "###Werbung_Wide", |
| 261 "###__ligatus_placeholder__", |
| 262 "###ad-bereich1-08", |
| 263 "###ad-bereich1-superbanner", |
| 264 "###ad-bereich2-08", |
| 265 "###ad-bereich2-skyscrapper" |
225 ]; | 266 ]; |
226 var knownFilters = filters.map(modules.filterClasses.Filter.fromText); | 267 var knownFilters = filters.map(modules.filterClasses.Filter.fromText); |
227 | 268 |
228 var subscriptions = [ | 269 var subscriptions = [ |
229 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", | 270 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", |
230 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", | 271 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", |
231 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", | 272 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", |
232 "~user~786254" | 273 "~user~786254" |
233 ]; | 274 ]; |
234 var knownSubscriptions = Object.create(null); | 275 var knownSubscriptions = Object.create(null); |
235 for (var subscriptionUrl of subscriptions) | 276 for (var subscriptionUrl of subscriptions) |
236 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti
on.fromURL(subscriptionUrl); | 277 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti
on.fromURL(subscriptionUrl); |
237 var customSubscription = knownSubscriptions["~user~786254"]; | 278 var customSubscription = knownSubscriptions["~user~786254"]; |
238 | 279 |
239 var issues = {seenDataCorruption: false, filterlistsReinitialized: false}; | 280 global.seenDataCorruption = params.seenDataCorruption; |
240 updateFromURL(issues); | 281 global.filterlistsReinitialized = params.filterlistsReinitialized; |
241 global.seenDataCorruption = issues.seenDataCorruption; | |
242 global.filterlistsReinitialized = issues.filterlistsReinitialized; | |
243 | 282 |
244 var events = {addSubscription: false}; | 283 if (params.addSubscription) |
245 updateFromURL(events); | |
246 if (events.addSubscription) | |
247 { | 284 { |
248 // 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 |
249 // so we'll post the message after one second | 286 // so we'll post the message after one second |
250 setTimeout(function() | 287 setTimeout(function() |
251 { | 288 { |
252 window.postMessage({ | 289 window.postMessage({ |
253 type: "message", | 290 type: "message", |
254 payload: { | 291 payload: { |
255 title: "Custom subscription", | 292 title: "Custom subscription", |
256 url: "http://example.com/custom.txt", | 293 url: "http://example.com/custom.txt", |
257 type: "add-subscription" | 294 type: "add-subscription" |
258 } | 295 } |
259 }, "*"); | 296 }, "*"); |
260 }, 1000); | 297 }, 1000); |
261 } | 298 } |
262 })(this); | 299 })(this); |
OLD | NEW |