MCPcopy Create free account
hub / github.com/NsLearning/LangHelper / Elements

Class Elements

ChatGPT/src-tauri/src/scripts/export.js:217–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215 }
216
217 class Elements {
218 constructor() {
219 this.init();
220 }
221 init() {
222 // this.threadWrapper = document.querySelector(".cdfdFe");
223 this.spacer = document.querySelector("[class*='h-48'].w-full.flex-shrink-0");
224 this.thread = document.querySelector(
225 "[class*='react-scroll-to-bottom']>[class*='react-scroll-to-bottom']>div"
226 );
227
228 // fix: old chat https://github.com/lencx/ChatGPT/issues/185
229 if (!this.thread) {
230 this.thread = document.querySelector("main .overflow-y-auto");
231 }
232
233 // h-full overflow-y-auto
234 this.positionForm = document.querySelector("form").parentNode;
235 // this.styledThread = document.querySelector("main");
236 // this.threadContent = document.querySelector(".gAnhyd");
237 this.scroller = Array.from(
238 document.querySelectorAll('[class*="react-scroll-to"]')
239 ).filter((el) => el.classList.contains("h-full"))[0];
240
241 // fix: old chat
242 if (!this.scroller) {
243 this.scroller = document.querySelector('main .overflow-y-auto');
244 }
245
246 this.hiddens = Array.from(document.querySelectorAll(".overflow-hidden"));
247 this.images = Array.from(document.querySelectorAll("img[srcset]"));
248 }
249 fixLocation() {
250 this.hiddens.forEach((el) => {
251 el.classList.remove("overflow-hidden");
252 });
253 this.spacer.style.display = "none";
254 this.thread.style.maxWidth = "960px";
255 this.thread.style.marginInline = "auto";
256 this.positionForm.style.display = "none";
257 this.scroller.classList.remove("h-full");
258 this.scroller.style.minHeight = "100vh";
259 this.images.forEach((img) => {
260 const srcset = img.getAttribute("srcset");
261 img.setAttribute("srcset_old", srcset);
262 img.setAttribute("srcset", "");
263 });
264 //Fix to the text shifting down when generating the canvas
265 document.body.style.lineHeight = "0.5";
266 }
267 restoreLocation() {
268 this.hiddens.forEach((el) => {
269 el.classList.add("overflow-hidden");
270 });
271 this.spacer.style.display = null;
272 this.thread.style.maxWidth = null;
273 this.thread.style.marginInline = null;
274 this.positionForm.style.display = null;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected