OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 // popup asks for them. | 499 // popup asks for them. |
500 function clickHide_mouseClick(e) | 500 function clickHide_mouseClick(e) |
501 { | 501 { |
502 if (!currentElement || !clickHide_activated) | 502 if (!currentElement || !clickHide_activated) |
503 return; | 503 return; |
504 | 504 |
505 var elt = currentElement; | 505 var elt = currentElement; |
506 if (currentElement.classList.contains("__adblockplus__overlay")) | 506 if (currentElement.classList.contains("__adblockplus__overlay")) |
507 elt = currentElement.prisoner; | 507 elt = currentElement.prisoner; |
508 | 508 |
509 clickHideFilters = new Array(); | 509 clickHideFilters = []; |
510 selectorList = new Array(); | 510 elemHideFilters = []; |
| 511 selectorList = []; |
511 | 512 |
512 var addSelector = function(selector) | 513 var addSelector = function(selector) |
513 { | 514 { |
514 if (selectorList.indexOf(selector) != -1) | 515 if (selectorList.indexOf(selector) != -1) |
515 return; | 516 return; |
516 | 517 |
517 clickHideFilters.push(document.domain + "##" + selector); | 518 var filter = document.domain + "##" + selector; |
| 519 clickHideFilters.push(filter); |
| 520 elemHideFilters.push(filter); |
| 521 |
518 selectorList.push(selector); | 522 selectorList.push(selector); |
519 }; | 523 }; |
520 | 524 |
521 if (elt.id) | 525 if (elt.id) |
522 addSelector("#" + escapeCSS(elt.id)); | 526 addSelector("#" + escapeCSS(elt.id)); |
523 | 527 |
524 if (elt.classList.length > 0) | 528 if (elt.classList.length > 0) |
525 { | 529 { |
526 var selector = ""; | 530 var selector = ""; |
527 | 531 |
(...skipping 23 matching lines...) Expand all Loading... |
551 } | 555 } |
552 | 556 |
553 // as last resort, create a filter based on inline styles | 557 // as last resort, create a filter based on inline styles |
554 if (clickHideFilters.length == 0) | 558 if (clickHideFilters.length == 0) |
555 { | 559 { |
556 var style = getOriginalStyle(elt); | 560 var style = getOriginalStyle(elt); |
557 if (style) | 561 if (style) |
558 addSelector(escapeCSS(elt.localName) + '[style=' + quote(style) + ']'); | 562 addSelector(escapeCSS(elt.localName) + '[style=' + quote(style) + ']'); |
559 } | 563 } |
560 | 564 |
561 // Show popup | 565 ext.backgroundPage.sendMessage( |
562 clickHide_showDialog(e.clientX, e.clientY, clickHideFilters); | 566 { |
| 567 type: "can-block", |
| 568 urls: urls, |
| 569 mediatype: typeMap[elt.localName], |
| 570 elemHideFilters: elemHideFilters |
| 571 }, |
563 | 572 |
564 // Highlight the elements specified by selector in yellow | 573 function(response) |
565 if (selectorList.length > 0) | 574 { |
566 highlightElements(selectorList.join(",")); | 575 if (response.canBlock) |
567 // Now, actually highlight the element the user clicked on in red | 576 { |
568 highlightElement(currentElement, "#fd1708", "#f6a1b5"); | 577 clickHide_showDialog(e.clientX, e.clientY, clickHideFilters); |
| 578 |
| 579 // Highlight the elements specified by selector in yellow |
| 580 if (selectorList.length > 0) |
| 581 highlightElements(selectorList.join(",")); |
| 582 |
| 583 // Now, actually highlight the element the user clicked on in red |
| 584 highlightElement(currentElement, "#fd1708", "#f6a1b5"); |
| 585 } |
| 586 else |
| 587 { |
| 588 clickHide_deactivate(); |
| 589 alert(response.reason); |
| 590 } |
| 591 } |
| 592 ); |
569 | 593 |
570 // Make sure the browser doesn't handle this click | 594 // Make sure the browser doesn't handle this click |
571 e.preventDefault(); | 595 e.preventDefault(); |
572 e.stopPropagation(); | 596 e.stopPropagation(); |
573 } | 597 } |
574 | 598 |
575 // This function Copyright (c) 2008 Jeni Tennison, from jquery.uri.js | 599 // This function Copyright (c) 2008 Jeni Tennison, from jquery.uri.js |
576 // and licensed under the MIT license. See jquery-*.min.js for details. | 600 // and licensed under the MIT license. See jquery-*.min.js for details. |
577 function removeDotSegments(u) { | 601 function removeDotSegments(u) { |
578 var r = '', m = []; | 602 var r = '', m = []; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 break; | 750 break; |
727 default: | 751 default: |
728 sendResponse({}); | 752 sendResponse({}); |
729 break; | 753 break; |
730 } | 754 } |
731 }); | 755 }); |
732 | 756 |
733 if (window == window.top) | 757 if (window == window.top) |
734 ext.backgroundPage.sendMessage({type: "report-html-page"}); | 758 ext.backgroundPage.sendMessage({type: "report-html-page"}); |
735 } | 759 } |
OLD | NEW |