LEFT | RIGHT |
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 { | 65 { |
66 let response = sendSyncMessage("AdblockPlus:ShouldAllow", { | 66 let response = sendSyncMessage("AdblockPlus:ShouldAllow", { |
67 contentType: contentType, | 67 contentType: contentType, |
68 location: location, | 68 location: location, |
69 frames: getFrames(window), | 69 frames: getFrames(window), |
70 isPrivate: isPrivate(window) | 70 isPrivate: isPrivate(window) |
71 }); | 71 }); |
72 if (response.length == 0) | 72 if (response.length == 0) |
73 return true; | 73 return true; |
74 | 74 |
75 let {allow, collapse, hits} = JSON.parse(response[0]); | 75 let {allow, collapse, hits} = response[0]; |
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; |
79 if (typeof frameIndex == "number") | 79 if (typeof frameIndex == "number") |
80 { | 80 { |
81 context = window; | 81 context = window; |
82 for (let i = 0; i < frameIndex; i++) | 82 for (let i = 0; i < frameIndex; i++) |
83 context = context.parent; | 83 context = context.parent; |
84 context = context.document; | 84 context = context.document; |
85 } | 85 } |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 /** | 312 /** |
313 * Processes nodes scheduled for post-processing (typically hides them). | 313 * Processes nodes scheduled for post-processing (typically hides them). |
314 */ | 314 */ |
315 function postProcessNodes() | 315 function postProcessNodes() |
316 { | 316 { |
317 if (!collapsedClass) | 317 if (!collapsedClass) |
318 { | 318 { |
319 let response = sendSyncMessage("AdblockPlus:GetCollapsedClass"); | 319 let response = sendSyncMessage("AdblockPlus:GetCollapsedClass"); |
320 if (response.length) | 320 if (response.length) |
321 collapsedClass = response[0]; | 321 collapsedClass = response[0]; |
322 | |
323 if (!collapsedClass) | |
324 { | |
325 Utils.runAsync(postProcessNodes); | |
326 return; | |
327 } | |
328 } | 322 } |
329 | 323 |
330 let nodes = scheduledNodes; | 324 let nodes = scheduledNodes; |
331 scheduledNodes = null; | 325 scheduledNodes = null; |
| 326 |
| 327 if (!collapsedClass) |
| 328 return; |
332 | 329 |
333 for (let node of nodes) | 330 for (let node of nodes) |
334 { | 331 { |
335 // adjust frameset's cols/rows for frames | 332 // adjust frameset's cols/rows for frames |
336 let parentNode = node.parentNode; | 333 let parentNode = node.parentNode; |
337 if (parentNode && parentNode instanceof Ci.nsIDOMHTMLFrameSetElement) | 334 if (parentNode && parentNode instanceof Ci.nsIDOMHTMLFrameSetElement) |
338 { | 335 { |
339 let hasCols = (parentNode.cols && parentNode.cols.indexOf(",") > 0); | 336 let hasCols = (parentNode.cols && parentNode.cols.indexOf(",") > 0); |
340 let hasRows = (parentNode.rows && parentNode.rows.indexOf(",") > 0); | 337 let hasRows = (parentNode.rows && parentNode.rows.indexOf(",") > 0); |
341 if ((hasCols || hasRows) && !(hasCols && hasRows)) | 338 if ((hasCols || hasRows) && !(hasCols && hasRows)) |
342 { | 339 { |
343 let index = -1; | 340 let index = -1; |
344 for (let frame = node; frame; frame = frame.previousSibling) | 341 for (let frame = node; frame; frame = frame.previousSibling) |
345 if (frame instanceof Ci.nsIDOMHTMLFrameElement || frame instanceof Ci.
nsIDOMHTMLFrameSetElement) | 342 if (frame instanceof Ci.nsIDOMHTMLFrameElement || frame instanceof Ci.
nsIDOMHTMLFrameSetElement) |
346 index++; | 343 index++; |
347 | 344 |
348 let property = (hasCols ? "cols" : "rows"); | 345 let property = (hasCols ? "cols" : "rows"); |
349 let weights = parentNode[property].split(","); | 346 let weights = parentNode[property].split(","); |
350 weights[index] = "0"; | 347 weights[index] = "0"; |
351 parentNode[property] = weights.join(","); | 348 parentNode[property] = weights.join(","); |
352 } | 349 } |
353 } | 350 } |
354 else | 351 else |
355 node.classList.add(collapsedClass); | 352 node.classList.add(collapsedClass); |
356 } | 353 } |
357 } | 354 } |
LEFT | RIGHT |