| Index: include.postload.js |
| =================================================================== |
| --- a/include.postload.js |
| +++ b/include.postload.js |
| @@ -1,6 +1,6 @@ |
| /* |
| * This file is part of Adblock Plus <http://adblockplus.org/>, |
| - * Copyright (C) 2006-2013 Eyeo GmbH |
| + * Copyright (C) 2006-2014 Eyeo GmbH |
| * |
| * Adblock Plus is free software: you can redistribute it and/or modify |
| * it under the terms of the GNU General Public License version 3 as |
| @@ -299,13 +299,15 @@ |
| clickHideFilters.push(document.domain + "###" + elementId); |
| selectorList.push("#" + elementId); |
| } |
| - if (elementClasses) |
| + if (elementClasses && elementClasses.length > 0) |
| { |
| - for(var i = 0; i < elementClasses.length; i++) |
| + var selector = elementClasses.map(function(elClass) |
| { |
| - clickHideFilters.push(document.domain + "##." + elementClasses[i]); |
| - selectorList.push("." + elementClasses[i]); |
| - } |
| + return "." + elClass.replace(/([^\w-])/, "\\$1"); |
| + }).join(""); |
| + |
| + clickHideFilters.push(document.domain + "##" + selector); |
| + selectorList.push(selector); |
| } |
| if (url) |
| { |
| @@ -353,32 +355,6 @@ |
| return url; |
| } |
| -// Converts relative to absolute URL |
| -// e.g.: foo.swf on http://example.com/whatever/bar.html |
| -// -> http://example.com/whatever/foo.swf |
| -function relativeToAbsoluteUrl(url) |
| -{ |
| - // If URL is already absolute, don't mess with it |
| - if (!url || /^[\w\-]+:/i.test(url)) |
| - return url; |
| - |
| - // Leading / means absolute path |
| - // Leading // means network path |
| - if (url[0] == '/') |
| - { |
| - if (url[1] == '/') |
| - return document.location.protocol + url; |
| - else |
| - return document.location.protocol + "//" + document.location.host + url; |
| - } |
| - |
| - // Remove filename and add relative URL to it |
| - var base = document.baseURI.match(/.+\//); |
| - if (!base) |
| - return document.baseURI + "/" + url; |
| - return base[0] + url; |
| -} |
| - |
| // This function Copyright (c) 2008 Jeni Tennison, from jquery.uri.js |
| // and licensed under the MIT license. See jquery-*.min.js for details. |
| function removeDotSegments(u) { |
| @@ -511,7 +487,7 @@ |
| clickHide_deactivate(); |
| break; |
| case "clickhide-new-filter": |
| - // The request is received by all frames, so ignore it if we're not the frame the |
| + // The message is received by all frames, so ignore it if we're not the frame the |
| // user right-clicked in |
| if(!lastRightClickEvent) |
| return; |
| @@ -542,7 +518,7 @@ |
| // Following test will be true if we found the element with the filter URL |
| if(msg.filter === url) |
| { |
| - // This request would have come from the chrome.contextMenu handler, so we |
| + // This message would have come from the chrome.contextMenu handler, so we |
| // simulate the user having chosen the element to get rid of via the usual means. |
| clickHide_activated = true; |
| // FIXME: clickHideFilters is erased in clickHide_mouseClick anyway, so why set it? |
| @@ -555,31 +531,41 @@ |
| clickHide_mouseClick(lastRightClickEvent); |
| } |
| else |
| - console.log("clickhide-new-filter: URLs don't match. Couldn't find that element.", request.filter, url, lastRightClickEvent.target.src); |
| + console.log("clickhide-new-filter: URLs don't match. Couldn't find that element.", msg.filter, url, lastRightClickEvent.target.src); |
| break; |
| case "clickhide-init": |
| if (clickHideFiltersDialog) |
| { |
| sendResponse({filters: clickHide_filters}); |
| - clickHideFiltersDialog.style.width = (msg.width + 5) + "px"; |
| - clickHideFiltersDialog.style.height = (msg.height + 5) + "px"; |
| + clickHideFiltersDialog.style.width = msg.width + "px"; |
| + clickHideFiltersDialog.style.height = msg.height + "px"; |
| clickHideFiltersDialog.style.visibility = "visible"; |
| } |
| break; |
| case "clickhide-move": |
| if (clickHideFiltersDialog) |
| { |
| - clickHideFiltersDialog.style.left = (parseInt(clickHideFiltersDialog.style.left, 10) + request.x) + "px"; |
| - clickHideFiltersDialog.style.top = (parseInt(clickHideFiltersDialog.style.top, 10) + request.y) + "px"; |
| + clickHideFiltersDialog.style.left = (parseInt(clickHideFiltersDialog.style.left, 10) + msg.x) + "px"; |
| + clickHideFiltersDialog.style.top = (parseInt(clickHideFiltersDialog.style.top, 10) + msg.y) + "px"; |
| } |
| break; |
| case "clickhide-close": |
| if (clickHideFiltersDialog) |
| { |
| // Explicitly get rid of currentElement |
| - if (msg.remove && currentElement && currentElement.parentNode) |
| - currentElement.parentNode.removeChild(currentElement); |
| + var element = currentElement; |
| + currentElement.parentNode.removeChild(currentElement); |
| + ext.backgroundPage.sendMessage({ |
| + type: "should-collapse", |
| + url: element.src, |
| + documentUrl: document.URL, |
| + mediatype: typeMap[element.localName] |
| + }, function(response) |
| + { |
| + if (response && element.parentNode) |
| + element.parentNode.removeChild(element); |
| + }); |
| clickHide_deactivate(); |
| } |