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

Side by Side Diff: include.preload.js

Issue 16067002: Added Safari Support (Closed)
Patch Set: Made description for Safari long again. The 100 char limit given by the extension builder doesn't a… Created Oct. 31, 2013, 2:12 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include.postload.js ('k') | lib/stats.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 var type = typeMap[tag]; 81 ext.backgroundPage.sendMessage(
82 chrome.extension.sendRequest({reqtype: "should-collapse", url: url, document Url: document.URL, type: type}, function(response)
83 {
84 if (response && target.parentNode)
85 { 82 {
86 // <frame> cannot be removed, doing that will mess up the frameset 83 type: "should-collapse",
87 if (tag == "frame") 84 url: url,
88 target.style.setProperty("visibility", "hidden", "!important"); 85 documentUrl: document.URL,
89 else 86 mediatype: typeMap[tag]
90 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 }
91 } 99 }
92 }); 100 );
93 } 101 }
94 } 102 }
95 103
96 function init() 104 function init()
97 { 105 {
98 // 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
99 if (!(document.documentElement instanceof HTMLElement)) 107 if (!(document.documentElement instanceof HTMLElement))
100 return; 108 return;
101 109
102 document.addEventListener("error", checkCollapse, true); 110 document.addEventListener("error", checkCollapse, true);
103 document.addEventListener("load", checkCollapse, true); 111 document.addEventListener("load", checkCollapse, true);
104 112
105 chrome.extension.sendRequest({reqtype: "get-settings", selectors: true, frameU rl: window.location.href}, function(response) 113 ext.backgroundPage.sendMessage(
106 { 114 {
107 setElemhideCSSRules(response.selectors); 115 type: "get-settings",
108 }); 116 selectors: true,
117 frameUrl: window.location.href
118 },
119
120 function(response)
121 {
122 setElemhideCSSRules(response.selectors);
123 }
124 );
109 } 125 }
110 126
111 // In Chrome 18 the document might not be initialized yet 127 // In Chrome 18 the document might not be initialized yet
112 if (document.documentElement) 128 if (document.documentElement)
113 init(); 129 init();
114 else 130 else
115 window.setTimeout(init, 0); 131 window.setTimeout(init, 0);
OLDNEW
« no previous file with comments | « include.postload.js ('k') | lib/stats.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld