mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
2
src-tauri/src/assets/core.js
vendored
2
src-tauri/src/assets/core.js
vendored
@@ -71,7 +71,7 @@ async function init() {
|
|||||||
|
|
||||||
document.addEventListener("click", (e) => {
|
document.addEventListener("click", (e) => {
|
||||||
const origin = e.target.closest("a");
|
const origin = e.target.closest("a");
|
||||||
if (!origin.target) return;
|
if (!origin || !origin.target) return;
|
||||||
if (origin && origin.href && origin.target !== '_self') {
|
if (origin && origin.href && origin.target !== '_self') {
|
||||||
invoke('open_link', { url: origin.href });
|
invoke('open_link', { url: origin.href });
|
||||||
}
|
}
|
||||||
|
|||||||
2
src-tauri/src/assets/dalle2.js
vendored
2
src-tauri/src/assets/dalle2.js
vendored
@@ -3,7 +3,7 @@
|
|||||||
async function init() {
|
async function init() {
|
||||||
document.addEventListener("click", (e) => {
|
document.addEventListener("click", (e) => {
|
||||||
const origin = e.target.closest("a");
|
const origin = e.target.closest("a");
|
||||||
if (!origin.target) return;
|
if (!origin || !origin.target) return;
|
||||||
if (origin && origin.href && origin.target !== '_self') {
|
if (origin && origin.href && origin.target !== '_self') {
|
||||||
if (/\/(login|signup)$/.test(window.location.href)) {
|
if (/\/(login|signup)$/.test(window.location.href)) {
|
||||||
origin.target = '_self';
|
origin.target = '_self';
|
||||||
|
|||||||
46
src-tauri/src/assets/export.js
vendored
46
src-tauri/src/assets/export.js
vendored
@@ -24,7 +24,7 @@ async function init() {
|
|||||||
} else if (shouldRemoveButtons()) {
|
} else if (shouldRemoveButtons()) {
|
||||||
removeButtons();
|
removeButtons();
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Format = {
|
const Format = {
|
||||||
@@ -47,9 +47,16 @@ function shouldRemoveButtons() {
|
|||||||
function shouldAddButtons(actionsArea) {
|
function shouldAddButtons(actionsArea) {
|
||||||
// first, check if there's a "Try Again" button and no other buttons
|
// first, check if there's a "Try Again" button and no other buttons
|
||||||
const buttons = actionsArea.querySelectorAll("button");
|
const buttons = actionsArea.querySelectorAll("button");
|
||||||
|
|
||||||
const hasTryAgainButton = Array.from(buttons).some((button) => {
|
const hasTryAgainButton = Array.from(buttons).some((button) => {
|
||||||
return !button.id?.includes("download");
|
return !button.id?.includes("download");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// fix: https://github.com/lencx/ChatGPT/issues/189
|
||||||
|
if (buttons.length === 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (hasTryAgainButton && buttons.length === 1) {
|
if (hasTryAgainButton && buttons.length === 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -106,16 +113,18 @@ function addActionsButtons(actionsArea, TryAgainButton) {
|
|||||||
downloadThread({ as: Format.PDF });
|
downloadThread({ as: Format.PDF });
|
||||||
};
|
};
|
||||||
actionsArea.appendChild(downloadPdfButton);
|
actionsArea.appendChild(downloadPdfButton);
|
||||||
const exportHtml = TryAgainButton.cloneNode(true);
|
|
||||||
exportHtml.id = "download-html-button";
|
// fix: https://github.com/lencx/ChatGPT/issues/126
|
||||||
downloadButton.setAttribute("share-ext", "true");
|
// const exportHtml = TryAgainButton.cloneNode(true);
|
||||||
// exportHtml.innerText = "Share Link";
|
// exportHtml.id = "download-html-button";
|
||||||
exportHtml.title = "Share Link";
|
// downloadButton.setAttribute("share-ext", "true");
|
||||||
exportHtml.innerHTML = setIcon('link');
|
// // exportHtml.innerText = "Share Link";
|
||||||
exportHtml.onclick = () => {
|
// exportHtml.title = "Share Link";
|
||||||
sendRequest();
|
// exportHtml.innerHTML = setIcon('link');
|
||||||
};
|
// exportHtml.onclick = () => {
|
||||||
actionsArea.appendChild(exportHtml);
|
// sendRequest();
|
||||||
|
// };
|
||||||
|
// actionsArea.appendChild(exportHtml);
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadThread({ as = Format.PNG } = {}) {
|
function downloadThread({ as = Format.PNG } = {}) {
|
||||||
@@ -175,12 +184,27 @@ class Elements {
|
|||||||
this.thread = document.querySelector(
|
this.thread = document.querySelector(
|
||||||
"[class*='react-scroll-to-bottom']>[class*='react-scroll-to-bottom']>div"
|
"[class*='react-scroll-to-bottom']>[class*='react-scroll-to-bottom']>div"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// fix: old chat https://github.com/lencx/ChatGPT/issues/185
|
||||||
|
if (!this.thread) {
|
||||||
|
this.thread = document.querySelector(
|
||||||
|
"main .overflow-y-auto"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// h-full overflow-y-auto
|
||||||
this.positionForm = document.querySelector("form").parentNode;
|
this.positionForm = document.querySelector("form").parentNode;
|
||||||
// this.styledThread = document.querySelector("main");
|
// this.styledThread = document.querySelector("main");
|
||||||
// this.threadContent = document.querySelector(".gAnhyd");
|
// this.threadContent = document.querySelector(".gAnhyd");
|
||||||
this.scroller = Array.from(
|
this.scroller = Array.from(
|
||||||
document.querySelectorAll('[class*="react-scroll-to"]')
|
document.querySelectorAll('[class*="react-scroll-to"]')
|
||||||
).filter((el) => el.classList.contains("h-full"))[0];
|
).filter((el) => el.classList.contains("h-full"))[0];
|
||||||
|
|
||||||
|
// fix: old chat
|
||||||
|
if (!this.scroller) {
|
||||||
|
this.scroller = document.querySelector('main .overflow-y-auto');
|
||||||
|
}
|
||||||
|
|
||||||
this.hiddens = Array.from(document.querySelectorAll(".overflow-hidden"));
|
this.hiddens = Array.from(document.querySelectorAll(".overflow-hidden"));
|
||||||
this.images = Array.from(document.querySelectorAll("img[srcset]"));
|
this.images = Array.from(document.querySelectorAll("img[srcset]"));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user