3
3
// @name:zh-CN ChatGPT Exporter
4
4
// @name:zh-TW ChatGPT Exporter
5
5
// @namespace pionxzh
6
- // @version 2.24.4
6
+ // @version 2.24.5
7
7
// @author pionxzh
8
8
// @description Easily export the whole ChatGPT conversation history for further analysis or sharing.
9
9
// @description:zh-CN 轻松导出 ChatGPT 聊天记录,以便进一步分析或分享。
@@ -1050,9 +1050,13 @@ html {
1050
1050
function getHistoryDisabled() {
1051
1051
return localStorage.getItem(KEY_OAI_HISTORY_DISABLED) === '"true"';
1052
1052
}
1053
+ function getPageAccessToken() {
1054
+ var _a, _b, _c, _d, _e, _f;
1055
+ return ((_f = (_e = (_d = (_c = (_b = (_a = _unsafeWindow == null ? void 0 : _unsafeWindow.__remixContext) == null ? void 0 : _a.state) == null ? void 0 : _b.loaderData) == null ? void 0 : _c.root) == null ? void 0 : _d.clientBootstrap) == null ? void 0 : _e.session) == null ? void 0 : _f.accessToken) ?? null;
1056
+ }
1053
1057
function getUserProfile() {
1054
- var _a, _b, _c;
1055
- const user = (_c = (_b = (_a = _unsafeWindow == null ? void 0 : _unsafeWindow.__NEXT_DATA__) == null ? void 0 : _a.props) == null ? void 0 : _b.pageProps) == null ? void 0 : _c.user;
1058
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i ;
1059
+ const user = (( _c = (_b = (_a = _unsafeWindow == null ? void 0 : _unsafeWindow.__NEXT_DATA__) == null ? void 0 : _a.props) == null ? void 0 : _b.pageProps) == null ? void 0 : _c.user) ?? ((_i = (_h = (_g = (_f = (_e = (_d = _unsafeWindow == null ? void 0 : _unsafeWindow.__remixContext) == null ? void 0 : _d.state) == null ? void 0 : _e.loaderData) == null ? void 0 : _f.root) == null ? void 0 : _g.clientBootstrap) == null ? void 0 : _h.session) == null ? void 0 : _i.user) ;
1056
1060
if (!user) throw new Error("No user found.");
1057
1061
return user;
1058
1062
}
@@ -1065,10 +1069,13 @@ html {
1065
1069
return location.pathname.startsWith("/share") && !location.pathname.endsWith("/continue");
1066
1070
}
1067
1071
function getConversationFromSharePage() {
1068
- var _a, _b, _c, _d;
1072
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i ;
1069
1073
if ((_d = (_c = (_b = (_a = window.__NEXT_DATA__) == null ? void 0 : _a.props) == null ? void 0 : _b.pageProps) == null ? void 0 : _c.serverResponse) == null ? void 0 : _d.data) {
1070
1074
return JSON.parse(JSON.stringify(window.__NEXT_DATA__.props.pageProps.serverResponse.data));
1071
1075
}
1076
+ if ((_i = (_h = (_g = (_f = (_e = window.__remixContext) == null ? void 0 : _e.state) == null ? void 0 : _f.loaderData) == null ? void 0 : _g["routes/share.$shareId.($action)"]) == null ? void 0 : _h.serverResponse) == null ? void 0 : _i.data) {
1077
+ return JSON.parse(JSON.stringify(window.__remixContext.state.loaderData["routes/share.$shareId.($action)"].serverResponse.data));
1078
+ }
1072
1079
return null;
1073
1080
}
1074
1081
const defaultAvatar = "data:image/svg+xml,%3Csvg%20stroke%3D%22currentColor%22%20fill%3D%22none%22%20stroke-width%3D%221.5%22%20viewBox%3D%22-6%20-6%2036%2036%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20style%3D%22color%3A%20white%3B%20background%3A%20%23ab68ff%3B%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M20%2021v-2a4%204%200%200%200-4-4H8a4%204%200%200%200-4%204v2%22%3E%3C%2Fpath%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%227%22%20r%3D%224%22%3E%3C%2Fcircle%3E%3C%2Fsvg%3E";
@@ -1249,6 +1256,8 @@ html {
1249
1256
}
1250
1257
const fetchSession = memorize(_fetchSession);
1251
1258
async function getAccessToken() {
1259
+ const pageAccessToken = getPageAccessToken();
1260
+ if (pageAccessToken) return pageAccessToken;
1252
1261
const session = await fetchSession();
1253
1262
return session.accessToken;
1254
1263
}
@@ -22719,24 +22728,24 @@ ${content2}`;
22719
22728
main();
22720
22729
function main() {
22721
22730
onloadSafe(() => {
22722
- const container = document.createElement("div");
22723
- container.style.zIndex = "20";
22724
- D$4(/* @__PURE__ */ o$8(Menu, { container }), container);
22725
22731
const styleEl = document.createElement("style");
22726
22732
styleEl.id = "sentinel-css";
22727
22733
document.head.append(styleEl);
22734
+ const injectionWeakMap = /* @__PURE__ */ new WeakMap();
22728
22735
sentinel.on("nav", (nav) => {
22729
- const chatList = document.querySelector("nav > div.overflow-y-auto, nav > div.overflow-y-hidden");
22736
+ if (injectionWeakMap.has(nav)) return;
22737
+ injectionWeakMap.set(nav, true);
22738
+ const container = getMenuContainer();
22739
+ const chatList = nav.querySelector(":scope > div.overflow-y-auto, :scope > div.overflow-y-hidden");
22730
22740
if (chatList) {
22731
22741
chatList.after(container);
22732
22742
} else {
22733
22743
nav.append(container);
22734
22744
}
22735
22745
});
22736
22746
if (isSharePage()) {
22737
- const continueUrl = `${location.href}/continue`;
22738
- sentinel.on(`a[href="${continueUrl}"]`, (link2) => {
22739
- link2.after(container);
22747
+ sentinel.on(`div[role="presentation"] > .w-full > div >.flex.w-full`, (target) => {
22748
+ target.prepend(getMenuContainer());
22740
22749
});
22741
22750
}
22742
22751
let chatId = "";
@@ -22769,5 +22778,11 @@ ${content2}`;
22769
22778
});
22770
22779
});
22771
22780
}
22781
+ function getMenuContainer() {
22782
+ const container = document.createElement("div");
22783
+ container.style.zIndex = "20";
22784
+ D$4(/* @__PURE__ */ o$8(Menu, { container }), container);
22785
+ return container;
22786
+ }
22772
22787
22773
22788
})(JSZip, html2canvas);
0 commit comments