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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 newSelector.push('[id=', selector.substring(pos.start + 1, pos.end), ']'); | 345 newSelector.push('[id=', selector.substring(pos.start + 1, pos.end), ']'); |
346 i = pos.end; | 346 i = pos.end; |
347 } | 347 } |
348 newSelector.push(selector.substring(i)); | 348 newSelector.push(selector.substring(i)); |
349 | 349 |
350 return newSelector.join(""); | 350 return newSelector.join(""); |
351 } | 351 } |
352 | 352 |
353 function addCSSRules(rules, selectors, matchDomain) | 353 function addCSSRules(rules, selectors, matchDomain) |
354 { | 354 { |
355 if (!matchDomain) | |
356 matchDomain = "^https?://"; | |
357 | |
358 while (selectors.length) | 355 while (selectors.length) |
Manish Jethani
2017/05/17 14:54:04
The rest of this function is a cut and paste from
| |
359 { | 356 { |
360 let selector = selectors.splice(0, selectorLimit).join(", "); | 357 let selector = selectors.splice(0, selectorLimit).join(", "); |
361 | 358 |
362 // As of Safari 9.0 element IDs are matched as lowercase. We work around | 359 // As of Safari 9.0 element IDs are matched as lowercase. We work around |
363 // this by converting to the attribute format [id="elementID"] | 360 // this by converting to the attribute format [id="elementID"] |
364 selector = convertIDSelectorsToAttributeSelectors(selector); | 361 selector = convertIDSelectorsToAttributeSelectors(selector); |
365 | 362 |
366 rules.push({ | 363 rules.push({ |
367 trigger: {"url-filter": matchDomain, | 364 trigger: {"url-filter": matchDomain, |
368 "url-filter-is-case-sensitive": true}, | 365 "url-filter-is-case-sensitive": true}, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
402 return; | 399 return; |
403 | 400 |
404 if (filter instanceof filterClasses.BlockingFilter) | 401 if (filter instanceof filterClasses.BlockingFilter) |
405 this.requestFilters.push(filter); | 402 this.requestFilters.push(filter); |
406 | 403 |
407 if (filter instanceof filterClasses.WhitelistFilter) | 404 if (filter instanceof filterClasses.WhitelistFilter) |
408 { | 405 { |
409 if (filter.contentType & (typeMap.DOCUMENT | whitelistableRequestTypes)) | 406 if (filter.contentType & (typeMap.DOCUMENT | whitelistableRequestTypes)) |
410 this.requestExceptions.push(filter); | 407 this.requestExceptions.push(filter); |
411 | 408 |
412 if (filter.contentType & typeMap.ELEMHIDE) | 409 if (filter.contentType & typeMap.ELEMHIDE) |
413 this.elemhideExceptions.push(filter); | 410 this.elemhideExceptions.push(filter); |
414 else if (filter.contentType & typeMap.GENERICHIDE) | 411 else if (filter.contentType & typeMap.GENERICHIDE) |
415 this.generichideExceptions.push(filter); | 412 this.generichideExceptions.push(filter); |
416 } | 413 } |
417 | 414 |
418 if (filter instanceof filterClasses.ElemHideFilter) | 415 if (filter instanceof filterClasses.ElemHideFilter) |
419 this.elemhideFilters.push(filter); | 416 this.elemhideFilters.push(filter); |
420 | 417 |
421 if (filter instanceof filterClasses.ElemHideException) | 418 if (filter instanceof filterClasses.ElemHideException) |
422 { | 419 { |
423 let domains = this.elemhideSelectorExceptions[filter.selector]; | 420 let domains = this.elemhideSelectorExceptions[filter.selector]; |
424 if (!domains) | 421 if (!domains) |
425 domains = this.elemhideSelectorExceptions[filter.selector] = []; | 422 domains = this.elemhideSelectorExceptions[filter.selector] = []; |
(...skipping 28 matching lines...) Expand all Loading... | |
454 { | 451 { |
455 for (let matchDomain of result.matchDomains) | 452 for (let matchDomain of result.matchDomains) |
456 { | 453 { |
457 let group = groupedElemhideFilters.get(matchDomain) || []; | 454 let group = groupedElemhideFilters.get(matchDomain) || []; |
458 group.push(result.selector); | 455 group.push(result.selector); |
459 groupedElemhideFilters.set(matchDomain, group); | 456 groupedElemhideFilters.set(matchDomain, group); |
460 } | 457 } |
461 } | 458 } |
462 } | 459 } |
463 | 460 |
464 addCSSRules(rules, genericSelectors); | 461 addCSSRules(rules, genericSelectors, "^https?://"); |
kzar
2017/05/19 12:12:22
Just pass matchDomain of ^https?:// here, then rem
| |
465 | 462 |
466 // Right after the generic element hiding filters, add the exceptions that | 463 // Right after the generic element hiding filters, add the exceptions that |
467 // should apply only to those filters. | 464 // should apply only to those filters. |
468 for (let filter of this.generichideExceptions) | 465 for (let filter of this.generichideExceptions) |
469 convertFilterAddRules(rules, filter, "ignore-previous-rules", false); | 466 convertFilterAddRules(rules, filter, "ignore-previous-rules", false); |
470 | 467 |
471 groupedElemhideFilters.forEach((selectors, matchDomain) => | 468 groupedElemhideFilters.forEach((selectors, matchDomain) => |
472 { | 469 { |
473 addCSSRules(rules, selectors, matchDomain); | 470 addCSSRules(rules, selectors, matchDomain); |
474 }); | 471 }); |
475 | 472 |
476 for (let filter of this.elemhideExceptions) | 473 for (let filter of this.elemhideExceptions) |
477 convertFilterAddRules(rules, filter, "ignore-previous-rules", false); | 474 convertFilterAddRules(rules, filter, "ignore-previous-rules", false); |
478 for (let filter of this.requestFilters) | 475 for (let filter of this.requestFilters) |
479 convertFilterAddRules(rules, filter, "block", true); | 476 convertFilterAddRules(rules, filter, "block", true); |
480 for (let filter of this.requestExceptions) | 477 for (let filter of this.requestExceptions) |
481 convertFilterAddRules(rules, filter, "ignore-previous-rules", true); | 478 convertFilterAddRules(rules, filter, "ignore-previous-rules", true); |
482 | 479 |
483 return rules.filter(rule => !hasNonASCI(rule)); | 480 return rules.filter(rule => !hasNonASCI(rule)); |
484 }; | 481 }; |
LEFT | RIGHT |