Skip to content

Commit

Permalink
chore: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
liady committed Dec 11, 2022
1 parent 61c28d1 commit 0dc107a
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/content_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,10 @@ function downloadThread({ as = Format.PNG } = {}) {
const minRatio = as === Format.PDF ? 2 : 2.5;
window.devicePixelRatio = Math.max(pixelRatio, minRatio);

//Fix to the text shifting down when generating the canvas
document.body.style.lineHeight = '0.5';

html2canvas(elements.thread, {
letterRendering: true,
}).then(async function (canvas) {
elements.restoreLocation();

//Restore style
document.body.style.lineHeight = null;

window.devicePixelRatio = pixelRatio;
const imgData = canvas.toDataURL("image/png");
requestAnimationFrame(() => {
Expand Down Expand Up @@ -172,6 +165,8 @@ class Elements {
img.setAttribute("srcset_old", srcset);
img.setAttribute("srcset", "");
});
//Fix to the text shifting down when generating the canvas
document.body.style.lineHeight = "0.5";
}
restoreLocation() {
this.hiddens.forEach((el) => {
Expand All @@ -188,6 +183,7 @@ class Elements {
img.setAttribute("srcset", srcset);
img.setAttribute("srcset_old", "");
});
document.body.style.lineHeight = null;
}
}

Expand Down

0 comments on commit 0dc107a

Please sign in to comment.