Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This Source Code is subject to the terms of the Mozilla Public License | 2 * This Source Code is subject to the terms of the Mozilla Public License |
3 * version 2.0 (the "License"). You can obtain a copy of the License at | 3 * version 2.0 (the "License"). You can obtain a copy of the License at |
4 * http://mozilla.org/MPL/2.0/. | 4 * http://mozilla.org/MPL/2.0/. |
5 */ | 5 */ |
6 | 6 |
7 var SELECTOR_GROUP_SIZE = 20; | 7 var SELECTOR_GROUP_SIZE = 20; |
8 | 8 |
9 var elemhideElt = null; | 9 var elemhideElt = null; |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 { | 54 { |
55 case "hide-element": | 55 case "hide-element": |
56 if (request.documentUrl != document.URL) | 56 if (request.documentUrl != document.URL) |
57 return; | 57 return; |
58 | 58 |
59 // We have little way of knowing which element was blocked - see | 59 // We have little way of knowing which element was blocked - see |
60 // http://code.google.com/p/chromium/issues/detail?id=97392. Have to | 60 // http://code.google.com/p/chromium/issues/detail?id=97392. Have to |
61 // look through all of them and try to find the right one. | 61 // look through all of them and try to find the right one. |
62 var remove = []; | 62 var remove = []; |
63 var elements = (request.type == "IMAGE" ? document.images : document.get ElementsByTagName("iframe")); | 63 var elements = (request.type == "IMAGE" ? document.images : document.get ElementsByTagName("iframe")); |
64 for (var i = 0; i < elements.length; i++) | 64 for (var i = 0, l = elements.length; i < l; i++) |
Thomas Greiner
2012/10/26 14:21:54
don't access elements.length on each iteration (cr
| |
65 if (elements[i].src == request.url) | 65 if (elements[i].src == request.url) |
66 remove.push(elements[i]); | 66 remove.push(elements[i]); |
Thomas Greiner
2012/10/26 14:21:54
we could break after we found one element
Wladimir Palant
2012/10/26 14:34:23
I don't think we should, it isn't necessarily a si
| |
67 | 67 |
68 for (var i = 0; i < remove.length; i++) | 68 for (var i = 0, l = remove.length; i < l; i++) |
Thomas Greiner
2012/10/26 14:21:54
not as important as with elements.length but still
| |
69 if (remove[i].parentNode) | 69 if (remove[i].parentNode) |
70 remove[i].parentNode.removeChild(remove[i]); | 70 remove[i].parentNode.removeChild(remove[i]); |
71 } | 71 } |
72 }); | 72 }); |
73 | 73 |
74 chrome.extension.sendRequest({reqtype: "get-settings", selectors: true, frameU rl: window.location.href}, function(response) | 74 chrome.extension.sendRequest({reqtype: "get-settings", selectors: true, frameU rl: window.location.href}, function(response) |
75 { | 75 { |
76 setElemhideCSSRules(response.selectors); | 76 setElemhideCSSRules(response.selectors); |
77 }); | 77 }); |
78 } | 78 } |
79 | 79 |
80 // In Chrome 18 the document might not be initialized yet | 80 // In Chrome 18 the document might not be initialized yet |
81 if (document.documentElement) | 81 if (document.documentElement) |
82 sendRequests(); | 82 sendRequests(); |
83 else | 83 else |
84 window.setTimeout(sendRequests, 0); | 84 window.setTimeout(sendRequests, 0); |
LEFT | RIGHT |