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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 13 matching lines...) Expand all Loading... | |
24 var sourcePage = new ext.Page({id: details.sourceTabId}); | 24 var sourcePage = new ext.Page({id: details.sourceTabId}); |
25 var sourceFrame = ext.getFrame(details.sourceTabId, details.sourceFrameId); | 25 var sourceFrame = ext.getFrame(details.sourceTabId, details.sourceFrameId); |
26 | 26 |
27 if (!sourceFrame || isFrameWhitelisted(sourcePage, sourceFrame)) | 27 if (!sourceFrame || isFrameWhitelisted(sourcePage, sourceFrame)) |
28 return; | 28 return; |
29 | 29 |
30 var documentHost = extractHostFromFrame(sourceFrame); | 30 var documentHost = extractHostFromFrame(sourceFrame); |
31 if (!documentHost) | 31 if (!documentHost) |
32 return; | 32 return; |
33 | 33 |
34 var specificOnly = isFrameWhitelisted(sourcePage, sourceFrame, "GENERICBLOCK "); | 34 var specificOnly = isFrameWhitelisted(sourcePage, sourceFrame, |
35 RegExpFilter.typeMap.GENERICBLOCK); | |
35 | 36 |
36 tabsLoading[details.tabId] = { | 37 tabsLoading[details.tabId] = { |
37 documentHost: documentHost, | 38 documentHost: documentHost, |
38 specificOnly: specificOnly | 39 specificOnly: specificOnly |
39 }; | 40 }; |
40 checkPotentialPopup(details.tabId, details.url, specificOnly, documentHost); | 41 checkPotentialPopup(details.tabId, details.url, documentHost, specificOnly); |
41 }); | 42 }); |
42 | 43 |
43 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) | 44 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) |
44 { | 45 { |
45 if (!(tabId in tabsLoading)) | 46 if (!(tabId in tabsLoading)) |
46 { | 47 { |
47 // Not a pop-up we've previously seen | 48 // Not a pop-up we've previously seen |
48 return; | 49 return; |
49 } | 50 } |
50 | 51 |
51 if ("url" in changeInfo) | 52 if ("url" in changeInfo) |
52 { | 53 { |
53 var source = tabsLoading[tabId]; | 54 var source = tabsLoading[tabId]; |
54 checkPotentialPopup(tabId, tab.url, source.specificOnly, source.documentHo st); | 55 checkPotentialPopup(tabId, tab.url, source.documentHost, |
56 source.specificOnly); | |
55 } | 57 } |
56 | 58 |
57 if ("status" in changeInfo && changeInfo.status == "complete" && tab.url != "about:blank") | 59 if ("status" in changeInfo && changeInfo.status == "complete" && tab.url != "about:blank") |
58 delete tabsLoading[tabId]; | 60 delete tabsLoading[tabId]; |
59 }); | 61 }); |
60 } | 62 } |
61 | 63 |
62 function checkPotentialPopup(tabId, url, specificOnly, documentHost) | 64 function checkPotentialPopup(tabId, url, documentHost, specificOnly) |
Sebastian Noack
2015/03/12 19:59:36
Nit: I'd put the documentHost first to match the s
kzar
2015/03/12 20:42:12
Done.
| |
63 { | 65 { |
64 url = new URL(url || "about:blank"); | 66 url = new URL(url || "about:blank"); |
65 | 67 |
66 var filter = defaultMatcher.matchesAny( | 68 var filter = defaultMatcher.matchesAny( |
67 stringifyURL(url), "POPUP", | 69 stringifyURL(url), RegExpFilter.typeMap.POPUP, |
68 documentHost, isThirdParty(url, documentHost), | 70 documentHost, isThirdParty(url, documentHost), |
69 undefined, specificOnly | 71 null, specificOnly |
Sebastian Noack
2015/03/12 19:59:36
Nit: Please null instead undefined.
kzar
2015/03/12 20:42:12
Done.
| |
70 ); | 72 ); |
71 | 73 |
72 if (filter instanceof BlockingFilter) | 74 if (filter instanceof BlockingFilter) |
73 chrome.tabs.remove(tabId); | 75 chrome.tabs.remove(tabId); |
74 } | 76 } |
LEFT | RIGHT |