Skip to content

Commit

Permalink
Fix bug when trying to capture very long page
Browse files Browse the repository at this point in the history
  • Loading branch information
deanoemcke committed Jun 6, 2017
1 parent ed7068b commit 57747b0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/js/contentscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,15 @@
}
}, 30000);

//if preview quality is high then capture the whole screen
//check where we need to capture the whole screen
if (screenCapture === '2') {
height = Math.max(document.body.scrollHeight,
document.body.offsetHeight,
document.documentElement.clientHeight,
document.documentElement.scrollHeight,
document.documentElement.offsetHeight);
// cap the max height otherwise it fails to convert to a data url
height = Math.min(height, 10000);
} else {
height = Math.min(document.body.offsetHeight, window.innerHeight);
}
Expand All @@ -144,7 +146,9 @@
if (processing) {
processing = false;
timer = (new Date() - timer) / 1000;
console.log('canvas: ' + canvas);
var dataUrl = canvas.toDataURL('image/webp', 0.8);
console.log('dataUrl: ' + dataUrl);
chrome.runtime.sendMessage({
action: 'savePreviewData',
previewUrl: dataUrl,
Expand Down

0 comments on commit 57747b0

Please sign in to comment.