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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 let canvas = E("screenshotCanvas"); | 356 let canvas = E("screenshotCanvas"); |
357 | 357 |
358 // Do not resize canvas any more (no idea why Gecko requires both to be set) | 358 // Do not resize canvas any more (no idea why Gecko requires both to be set) |
359 canvas.parentNode.style.MozBoxAlign = "center"; | 359 canvas.parentNode.style.MozBoxAlign = "center"; |
360 canvas.parentNode.align = "center"; | 360 canvas.parentNode.align = "center"; |
361 | 361 |
362 let context = canvas.getContext("2d"); | 362 let context = canvas.getContext("2d"); |
363 this._canvas = canvas; | 363 this._canvas = canvas; |
364 this._context = context; | 364 this._context = context; |
365 | 365 |
366 let drawScreenshot = new Promise((resolve, reject) => { | 366 if (screenshot) |
367 if (screenshot) | 367 { |
368 { | 368 canvas.width = screenshot.width + this.imageOffset * 2; |
369 let image = new Image(); | 369 canvas.height = screenshot.height + this.imageOffset * 2; |
370 image.src = screenshot; | 370 context.putImageData(screenshot, this.imageOffset, this.imageOffset); |
371 image.addEventListener("load", () => { | 371 } |
372 canvas.width = image.width + this.imageOffset * 2; | 372 |
373 canvas.height = image.height + this.imageOffset * 2; | 373 // Init canvas settings |
374 context.drawImage(image, this.imageOffset, this.imageOffset); | 374 context.fillStyle = "rgb(0, 0, 0)"; |
375 resolve(); | 375 context.strokeStyle = "rgba(255, 0, 0, 0.7)"; |
376 }); | 376 context.lineWidth = 3; |
377 } | 377 context.lineJoin = "round"; |
378 else | |
379 resolve(); | |
380 }); | |
381 | |
382 drawScreenshot.then(() => { | |
383 // Init canvas settings, this has to be done after the canvas size is set | |
384 context.fillStyle = "rgb(0, 0, 0)"; | |
385 context.strokeStyle = "rgba(255, 0, 0, 0.7)"; | |
386 context.lineWidth = 3; | |
387 context.lineJoin = "round"; | |
388 }); | |
389 }, | 378 }, |
390 | 379 |
391 get enabled() | 380 get enabled() |
392 { | 381 { |
393 return this._enabled | 382 return this._enabled |
394 }, | 383 }, |
395 set enabled(enabled) | 384 set enabled(enabled) |
396 { | 385 { |
397 if (this._enabled == enabled) | 386 if (this._enabled == enabled) |
398 return; | 387 return; |
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 | 1549 |
1561 function censorURL(url) | 1550 function censorURL(url) |
1562 { | 1551 { |
1563 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*"); | 1552 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*"); |
1564 } | 1553 } |
1565 | 1554 |
1566 function encodeHTML(str) | 1555 function encodeHTML(str) |
1567 { | 1556 { |
1568 return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").
replace(/"/g, """); | 1557 return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").
replace(/"/g, """); |
1569 } | 1558 } |
LEFT | RIGHT |