| Index: popupBlocker.js |
| =================================================================== |
| --- a/popupBlocker.js |
| +++ b/popupBlocker.js |
| @@ -15,51 +15,16 @@ |
| * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| */ |
| -if (require("info").platform == "chromium") |
| +ext.pages.onPopup.addListener(function(page, opener) |
| { |
| - var tabsLoading = {}; |
| + if (isFrameWhitelisted(opener.page, opener.frame)) |
| + return; |
| - chrome.webNavigation.onCreatedNavigationTarget.addListener(function(details) |
| - { |
| - var sourcePage = new ext.Page({id: details.sourceTabId}); |
| - var sourceFrame = ext.getFrame(details.sourceTabId, details.sourceFrameId); |
| + var requestHost = extractHostFromURL(page.url); |
| + var documentHost = extractHostFromURL(opener.frame.url); |
| + var thirdParty = isThirdParty(requestHost, documentHost); |
| + var filter = defaultMatcher.matchesAny(page.url, "POPUP", documentHost, thirdParty); |
| - if (!sourceFrame || isFrameWhitelisted(sourcePage, sourceFrame)) |
| - return; |
| - |
| - var openerUrl = sourceFrame.url; |
| - if (!openerUrl) |
| - { |
| - // We don't know the opener tab |
| - return; |
| - } |
| - tabsLoading[details.tabId] = openerUrl; |
| - |
| - checkPotentialPopup(details.tabId, details.url, openerUrl); |
| - }); |
| - |
| - chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) |
| - { |
| - if (!(tabId in tabsLoading)) |
| - { |
| - // Not a pop-up we've previously seen |
| - return; |
| - } |
| - |
| - if ("url" in changeInfo) |
| - checkPotentialPopup(tabId, tab.url, tabsLoading[tabId]); |
| - |
| - if ("status" in changeInfo && changeInfo.status == "complete" && tab.url != "about:blank") |
| - delete tabsLoading[tabId]; |
| - }); |
| -} |
| - |
| -function checkPotentialPopup(tabId, url, opener) |
| -{ |
| - var requestHost = extractHostFromURL(url); |
| - var documentHost = extractHostFromURL(opener); |
| - var thirdParty = isThirdParty(requestHost, documentHost); |
| - var filter = defaultMatcher.matchesAny(url || "about:blank", "POPUP", documentHost, thirdParty); |
| if (filter instanceof BlockingFilter) |
| - chrome.tabs.remove(tabId); |
| -} |
| + page.close(); |
| +}); |