feat: add go to config (#24)

This commit is contained in:
lencx
2022-12-12 23:03:46 +08:00
parent bb44cdd5b7
commit 918d53c9b9
4 changed files with 19 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
// *** Core Script - Export ***
// @ref: https://github.com/liady/ChatGPT-pdf/blob/main/src/content_script.js
// @ref: https://github.com/liady/ChatGPT-pdf
async function init() {
const chatConf = await invoke('get_chat_conf') || {};
@@ -78,22 +78,9 @@ function downloadThread({ as = Format.PNG } = {}) {
const pixelRatio = window.devicePixelRatio;
const minRatio = as === Format.PDF ? 2 : 2.5;
window.devicePixelRatio = Math.max(pixelRatio, minRatio);
html2canvas(elements.thread, {
letterRendering: true,
onclone: function (cloneDoc) {
//Make small fix of position to all the text containers
let listOfTexts = cloneDoc.getElementsByClassName("min-h-[20px]");
Array.from(listOfTexts).forEach((text) => {
text.style.position = "relative";
text.style.top = "-8px";
});
//Delete copy button from code blocks
let listOfCopyBtns = cloneDoc.querySelectorAll("button.flex");
Array.from(listOfCopyBtns).forEach(
(btn) => (btn.style.visibility = "hidden")
);
},
}).then(async function (canvas) {
elements.restoreLocation();
window.devicePixelRatio = pixelRatio;
@@ -166,6 +153,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) => {
@@ -182,6 +171,7 @@ class Elements {
img.setAttribute("srcset", srcset);
img.setAttribute("srcset_old", "");
});
document.body.style.lineHeight = null;
}
}