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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 // When the user clicks, the currentElement is the one we want. | 361 // When the user clicks, the currentElement is the one we want. |
362 // We should have ABP rules ready for when the | 362 // We should have ABP rules ready for when the |
363 // popup asks for them. | 363 // popup asks for them. |
364 function clickHide_mouseClick(e) | 364 function clickHide_mouseClick(e) |
365 { | 365 { |
366 if (!currentElement || !clickHide_activated) | 366 if (!currentElement || !clickHide_activated) |
367 return; | 367 return; |
368 | 368 |
369 var elt = currentElement; | 369 var elt = currentElement; |
370 var url = null; | 370 var url = null; |
371 if (currentElement.className && currentElement.className == "__adblockplus__ov
erlay") | 371 if (currentElement.classList.contains("__adblockplus__overlay")) |
372 { | 372 { |
373 elt = currentElement.prisoner; | 373 elt = currentElement.prisoner; |
374 url = currentElement.prisonerURL; | 374 url = currentElement.prisonerURL; |
375 } | 375 } |
376 else if (elt.src) | 376 else if (elt.src) |
377 url = elt.src; | 377 url = elt.src; |
378 | 378 |
379 // Construct filters. The popup will retrieve these. | 379 // Construct filters. The popup will retrieve these. |
380 // Only one ID | 380 // Only one ID |
381 var elementId = elt.id ? elt.id.split(' ').join('') : null; | 381 var elementId = elt.id ? elt.id.split(' ').join('') : null; |
382 // Can have multiple classes, and there might be extraneous whitespace | |
383 var elementClasses = null; | |
384 if (elt.className) | |
385 elementClasses = elt.className.replace(/\s+/g, ' ').replace(/^\s+|\s+$/g, ''
).split(' '); | |
386 | 382 |
387 clickHideFilters = new Array(); | 383 clickHideFilters = new Array(); |
388 selectorList = new Array(); | 384 selectorList = new Array(); |
389 | 385 |
390 var addSelector = function(selector) | 386 var addSelector = function(selector) |
391 { | 387 { |
392 clickHideFilters.push(document.domain + "##" + selector); | 388 clickHideFilters.push(document.domain + "##" + selector); |
393 selectorList.push(selector); | 389 selectorList.push(selector); |
394 }; | 390 }; |
395 | 391 |
396 if (elementId) | 392 if (elementId) |
397 addSelector("#" + elementId); | 393 addSelector("#" + elementId); |
398 | 394 |
399 if (elementClasses && elementClasses.length > 0) | 395 if (elt.classList.length > 0) |
400 { | 396 { |
401 var selector = ""; | 397 var selector = ""; |
402 | 398 |
403 for (var i = 0; i < elt.classList.length; i++) | 399 for (var i = 0; i < elt.classList.length; i++) |
404 selector += "." + elt.classList[i].replace(/([^\w-])/g, "\\$1"); | 400 selector += "." + elt.classList[i].replace(/([^\w-])/g, "\\$1"); |
405 | 401 |
406 addSelector(selector); | 402 addSelector(selector); |
407 } | 403 } |
408 | 404 |
409 if (url) | 405 if (url) |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 break; | 659 break; |
664 default: | 660 default: |
665 sendResponse({}); | 661 sendResponse({}); |
666 break; | 662 break; |
667 } | 663 } |
668 }); | 664 }); |
669 | 665 |
670 if (window == window.top) | 666 if (window == window.top) |
671 ext.backgroundPage.sendMessage({type: "report-html-page"}); | 667 ext.backgroundPage.sendMessage({type: "report-html-page"}); |
672 } | 668 } |
OLD | NEW |