OLD | NEW |
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 * Checks whether a request should be allowed, hides it if necessary | 58 * Checks whether a request should be allowed, hides it if necessary |
59 * @param wnd {nsIDOMWindow} | 59 * @param wnd {nsIDOMWindow} |
60 * @param node {nsIDOMElement} | 60 * @param node {nsIDOMElement} |
61 * @param contentType {String} | 61 * @param contentType {String} |
62 * @param location {String} | 62 * @param location {String} |
63 * @param [callback] {Function} If present, the request will be sent | 63 * @param [callback] {Function} If present, the request will be sent |
64 * asynchronously and callback called with the | 64 * asynchronously and callback called with the |
65 * response | 65 * response |
66 * @return {Boolean} false if the request should be blocked | 66 * @return {Boolean} false if the request should be blocked |
67 */ | 67 */ |
68 function shouldAllow(window, node, contentType, location, callback) | 68 let shouldAllow = exports.shouldAllow = function(window, node, contentType, loca
tion, callback) |
69 { | 69 { |
70 function processResponse(response) | 70 function processResponse(response) |
71 { | 71 { |
72 if (typeof response == "undefined") | 72 if (typeof response == "undefined") |
73 return true; | 73 return true; |
74 | 74 |
75 let {allow, collapse, hits} = response; | 75 let {allow, collapse, hits} = response; |
76 for (let {frameIndex, contentType, docDomain, thirdParty, location, filter}
of hits) | 76 for (let {frameIndex, contentType, docDomain, thirdParty, location, filter}
of hits) |
77 { | 77 { |
78 let context = node; | 78 let context = node; |
(...skipping 29 matching lines...) Expand all Loading... |
108 isPrivate: isPrivate(window) | 108 isPrivate: isPrivate(window) |
109 }; | 109 }; |
110 if (typeof callback == "function") | 110 if (typeof callback == "function") |
111 { | 111 { |
112 sendAsyncMessage("AdblockPlus:ShouldAllow", data, (data) => { | 112 sendAsyncMessage("AdblockPlus:ShouldAllow", data, (data) => { |
113 callback(processResponse(data)); | 113 callback(processResponse(data)); |
114 }); | 114 }); |
115 } | 115 } |
116 else | 116 else |
117 return processResponse(sendSyncMessage("AdblockPlus:ShouldAllow", data)); | 117 return processResponse(sendSyncMessage("AdblockPlus:ShouldAllow", data)); |
118 } | 118 }; |
119 | 119 |
120 /** | 120 /** |
121 * Actual nsIContentPolicy and nsIChannelEventSink implementation | 121 * Actual nsIContentPolicy and nsIChannelEventSink implementation |
122 * @class | 122 * @class |
123 */ | 123 */ |
124 var PolicyImplementation = | 124 var PolicyImplementation = |
125 { | 125 { |
126 classDescription: "Adblock Plus content policy", | 126 classDescription: "Adblock Plus content policy", |
127 classID: Components.ID("cfeaabe6-1dd1-11b2-a0c6-cb5c268894c9"), | 127 classID: Components.ID("cfeaabe6-1dd1-11b2-a0c6-cb5c268894c9"), |
128 contractID: "@adblockplus.org/abp/policy;1", | 128 contractID: "@adblockplus.org/abp/policy;1", |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 let property = (hasCols ? "cols" : "rows"); | 366 let property = (hasCols ? "cols" : "rows"); |
367 let weights = parentNode[property].split(","); | 367 let weights = parentNode[property].split(","); |
368 weights[index] = "0"; | 368 weights[index] = "0"; |
369 parentNode[property] = weights.join(","); | 369 parentNode[property] = weights.join(","); |
370 } | 370 } |
371 } | 371 } |
372 else | 372 else |
373 node.classList.add(collapsedClass); | 373 node.classList.add(collapsedClass); |
374 } | 374 } |
375 } | 375 } |
OLD | NEW |