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

Delta Between Two Patch Sets: include.preload.js

Issue 16067002: Added Safari Support (Closed)
Left Patch Set: Created Oct. 21, 2013, 8:11 p.m.
Right Patch Set: Bugfixes Created Nov. 15, 2013, 8:58 a.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/stats.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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 var target = event.target; 71 var target = event.target;
72 var tag = target.localName; 72 var tag = target.localName;
73 var expectedEvent = (tag == "iframe" || tag == "frame" ? "load" : "error"); 73 var expectedEvent = (tag == "iframe" || tag == "frame" ? "load" : "error");
74 if (tag in typeMap && event.type == expectedEvent) 74 if (tag in typeMap && event.type == expectedEvent)
75 { 75 {
76 // This element failed loading, did we block it? 76 // This element failed loading, did we block it?
77 var url = target.src; 77 var url = target.src;
78 if (!url) 78 if (!url)
79 return; 79 return;
80 80
81 ext.backgroundPage.sendMessage({ 81 ext.backgroundPage.sendMessage(
82 type: "should-collapse",
83 url: url,
84 documentUrl: document.URL,
85 mediatype: typeMap[tag]
86 }, function(response) {
87 if (response && target.parentNode)
88 { 82 {
89 // <frame> cannot be removed, doing that will mess up the frameset 83 type: "should-collapse",
90 if (tag == "frame") 84 url: url,
91 target.style.setProperty("visibility", "hidden", "!important"); 85 documentUrl: document.URL,
92 else 86 mediatype: typeMap[tag]
93 target.parentNode.removeChild(target); 87 },
88
89 function(response)
90 {
91 if (response && target.parentNode)
92 {
93 // <frame> cannot be removed, doing that will mess up the frameset
94 if (tag == "frame")
95 target.style.setProperty("visibility", "hidden", "!important");
96 else
97 target.parentNode.removeChild(target);
98 }
94 } 99 }
95 }); 100 );
96 } 101 }
97 } 102 }
98 103
99 function init() 104 function init()
100 { 105 {
101 // Make sure this is really an HTML page, as Chrome runs these scripts on just about everything 106 // Make sure this is really an HTML page, as Chrome runs these scripts on just about everything
102 if (!(document.documentElement instanceof HTMLElement)) 107 if (!(document.documentElement instanceof HTMLElement))
103 return; 108 return;
104 109
105 document.addEventListener("error", checkCollapse, true); 110 document.addEventListener("error", checkCollapse, true);
106 document.addEventListener("load", checkCollapse, true); 111 document.addEventListener("load", checkCollapse, true);
107 112
108 ext.backgroundPage.sendMessage({ 113 ext.backgroundPage.sendMessage(
109 type: "get-settings", 114 {
110 selectors: true, 115 type: "get-selectors",
111 frameUrl: window.location.href 116 frameUrl: window.location.href
112 }, function(response) { 117 },
113 setElemhideCSSRules(response.selectors); 118 setElemhideCSSRules
114 }); 119 );
115 } 120 }
116 121
117 // In Chrome 18 the document might not be initialized yet 122 // In Chrome 18 the document might not be initialized yet
118 if (document.documentElement) 123 if (document.documentElement)
119 init(); 124 init();
120 else 125 else
121 window.setTimeout(init, 0); 126 window.setTimeout(init, 0);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld