Skip to content

Commit 959eeec

Browse files
committed
feat: separate css
1 parent 4d932b8 commit 959eeec

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/content_script.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ function downloadThread({ as = Format.PNG } = {}) {
7272
const pixelRatio = window.devicePixelRatio;
7373
const minRatio = as === Format.PDF ? 2 : 2.5;
7474
window.devicePixelRatio = Math.max(pixelRatio, minRatio);
75-
html2canvas(elements.thread).then(async function (canvas) {
75+
html2canvas(elements.thread, {
76+
letterRendering: true,
77+
}).then(async function (canvas) {
7678
elements.restoreLocation();
7779
window.devicePixelRatio = pixelRatio;
7880
const imgData = canvas.toDataURL("image/png");
@@ -144,6 +146,7 @@ class Elements {
144146
this.scroller = Array.from(
145147
document.querySelectorAll('[class*="react-scroll-to"]')
146148
).filter((el) => el.classList.contains("h-full"))[0];
149+
this.images = Array.from(document.querySelectorAll("img[srcset]"));
147150
}
148151
fixLocation() {
149152
this.threadWrapper.style.overflow = "auto";
@@ -155,6 +158,11 @@ class Elements {
155158
this.positionForm.style.display = "none";
156159
this.scroller.classList.remove("h-full");
157160
this.scroller.style.minHeight = "100vh";
161+
this.images.forEach((img) => {
162+
const srcset = img.getAttribute("srcset");
163+
img.setAttribute("srcset_old", srcset);
164+
img.setAttribute("srcset", "");
165+
});
158166
}
159167
restoreLocation() {
160168
this.threadWrapper.style.overflow = null;
@@ -166,6 +174,11 @@ class Elements {
166174
this.positionForm.style.display = null;
167175
this.scroller.classList.add("h-full");
168176
this.scroller.style.minHeight = null;
177+
this.images.forEach((img) => {
178+
const srcset = img.getAttribute("srcset_old");
179+
img.setAttribute("srcset", srcset);
180+
img.setAttribute("srcset_old", "");
181+
});
169182
}
170183
}
171184

@@ -202,7 +215,9 @@ function getData() {
202215
);
203216
const data = {
204217
main: document.querySelector("main").outerHTML,
205-
css: `${globalCss} ${localCss}`,
218+
// css: `${globalCss} /* GLOBAL-LOCAL */ ${localCss}`,
219+
globalCss,
220+
localCss,
206221
};
207222
return data;
208223
}

src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "ChatGPT Download",
44
"description": "Download a PNG or PDF of your chat with ChatGPT",
5-
"version": "1.0.0",
5+
"version": "1.1.1",
66
"author": "Liad Yosef",
77
"icons": {
88
"48": "icons/48.png"

0 commit comments

Comments
 (0)