| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 data: null | 52 data: null |
| 53 }); | 53 }); |
| 54 } | 54 } |
| 55 | 55 |
| 56 let window = Services.wm.getOuterWindowWithId(outerWindowID); | 56 let window = Services.wm.getOuterWindowWithId(outerWindowID); |
| 57 if (window) | 57 if (window) |
| 58 { | 58 { |
| 59 Task.spawn(function*() | 59 Task.spawn(function*() |
| 60 { | 60 { |
| 61 let data = {}; | 61 let data = {}; |
| 62 data.opener = window.opener ? window.opener.location.href : null; |
| 63 data.referrer = window.document.referrer; |
| 64 data.frames = yield scanFrames(window); |
| 62 data.screenshot = yield createScreenshot(window, screenshotWidth); | 65 data.screenshot = yield createScreenshot(window, screenshotWidth); |
| 63 return data; | 66 return data; |
| 64 }).then(success, error); | 67 }).then(success, error); |
| 65 } | 68 } |
| 66 } | 69 } |
| 67 | 70 |
| 71 function scanFrames(window) |
| 72 { |
| 73 let frames = []; |
| 74 for (let i = 0; i < window.frames.length; i++) |
| 75 { |
| 76 let frame = window.frames[i]; |
| 77 frames.push({ |
| 78 url: frame.location.href, |
| 79 frames: scanFrames(frame) |
| 80 }); |
| 81 } |
| 82 return frames; |
| 83 } |
| 84 |
| 68 function* createScreenshot(window, screenshotWidth) | 85 function* createScreenshot(window, screenshotWidth) |
| 69 { | 86 { |
| 70 let canvas = window.document.createElement("canvas"); | 87 let canvas = window.document.createElement("canvas"); |
| 71 canvas.width = screenshotWidth; | 88 canvas.width = screenshotWidth; |
| 72 | 89 |
| 73 let context = canvas.getContext("2d"); | 90 let context = canvas.getContext("2d"); |
| 74 let wndWidth = window.document.documentElement.scrollWidth; | 91 let wndWidth = window.document.documentElement.scrollWidth; |
| 75 let wndHeight = window.document.documentElement.scrollHeight; | 92 let wndHeight = window.document.documentElement.scrollHeight; |
| 76 | 93 |
| 77 // Copy scaled screenshot of the webpage, according to the specified width. | 94 // Copy scaled screenshot of the webpage, according to the specified width. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 103 { | 120 { |
| 104 // Take a break every 5000 bytes to prevent browser hangs | 121 // Take a break every 5000 bytes to prevent browser hangs |
| 105 yield new Promise((resolve, reject) => Utils.runAsync(resolve)); | 122 yield new Promise((resolve, reject) => Utils.runAsync(resolve)); |
| 106 } | 123 } |
| 107 } | 124 } |
| 108 | 125 |
| 109 // Convert the data into an image URL | 126 // Convert the data into an image URL |
| 110 context.putImageData(pixelData, 0, 0); | 127 context.putImageData(pixelData, 0, 0); |
| 111 return canvas.toDataURL("image/png"); | 128 return canvas.toDataURL("image/png"); |
| 112 } | 129 } |
| OLD | NEW |