Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: include.preload.js

Issue 6174977720057856: Issue 1853 - Moved filter generation into background page (Closed)
Left Patch Set: Created Jan. 25, 2015, 1:21 p.m.
Right Patch Set: Rebased and fixed documentation mistakenly indicating arguments as optional Created Feb. 28, 2015, 5:59 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « include.postload.js ('k') | lib/filterComposer.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 } 70 }
71 71
72 function checkSitekey() 72 function checkSitekey()
73 { 73 {
74 var attr = document.documentElement.getAttribute("data-adblockkey"); 74 var attr = document.documentElement.getAttribute("data-adblockkey");
75 if (attr) 75 if (attr)
76 ext.backgroundPage.sendMessage({type: "add-sitekey", token: attr}); 76 ext.backgroundPage.sendMessage({type: "add-sitekey", token: attr});
77 } 77 }
78 78
79 function hasInlineURL(element, attribute)
80 {
81 var value = element.getAttribute(attribute);
82 return value == null || /^\s*(javascript:|about:|$)/i.test(value);
83 }
84
85 function isInlineFrame(element) 79 function isInlineFrame(element)
86 { 80 {
87 switch (element.localName) 81 var contentDocument;
88 { 82 try
89 case "iframe": 83 {
90 return hasInlineURL(element, "src") || element.hasAttribute("srcdoc"); 84 contentDocument = element.contentDocument;
91 case "frame": 85 }
92 return hasInlineURL(element, "src"); 86 catch (e)
93 case "object": 87 {
94 return hasInlineURL(element, "data") && element.contentDocument; 88 return false; // third-party
95 default: 89 }
96 return false; 90
97 } 91 if (!contentDocument)
92 return false; // not a frame
93
94 return contentDocument.location.protocol == "about:";
98 } 95 }
99 96
100 function reinjectRulesWhenRemoved(document, style) 97 function reinjectRulesWhenRemoved(document, style)
101 { 98 {
102 var MutationObserver = window.MutationObserver || window.WebKitMutationObserve r; 99 var MutationObserver = window.MutationObserver || window.WebKitMutationObserve r;
103 if (!MutationObserver) 100 if (!MutationObserver)
104 return; 101 return;
105 102
106 var observer = new MutationObserver(function(mutations) 103 var observer = new MutationObserver(function(mutations)
107 { 104 {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 }, true); 263 }, true);
267 264
268 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules); 265 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules);
269 } 266 }
270 267
271 if (document instanceof HTMLDocument) 268 if (document instanceof HTMLDocument)
272 { 269 {
273 checkSitekey(); 270 checkSitekey();
274 init(document); 271 init(document);
275 } 272 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld