Skip to content

Commit

Permalink
fix: can't close MOSS login window
Browse files Browse the repository at this point in the history
close #527
  • Loading branch information
sunner committed Aug 31, 2023
1 parent 87c276a commit 7916d25
Showing 1 changed file with 36 additions and 32 deletions.
68 changes: 36 additions & 32 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,38 +238,42 @@ function createNewWindow(url, userAgent = "") {
newWin.on("close", async (e) => {
e.preventDefault(); // Prevent the window from closing

// Hacking secrets
const getLocalStorage = async (key) => {
return await newWin.webContents.executeJavaScript(
`localStorage.getItem("${key}");`,
);
};
if (url.startsWith("https://moss.fastnlp.top/")) {
// Get the secret of MOSS
const secret = await getLocalStorage("flutter.token");
mainWindow.webContents.send("moss-secret", secret);
} else if (url.startsWith("https://qianwen.aliyun.com/")) {
// Get QianWen bot's XSRF-TOKEN
const token = await newWin.webContents.executeJavaScript(
'document.cookie.split("; ").find((cookie) => cookie.startsWith("XSRF-TOKEN="))?.split("=")[1];',
);
mainWindow.webContents.send("QIANWEN-XSRF-TOKEN", token);
} else if (url.startsWith("https://neice.tiangong.cn/")) {
// Get the tokens of SkyWork
const inviteToken = await getLocalStorage("formNatureQueueWaitToken");
const token = await getLocalStorage("formNatureResearchToken");
mainWindow.webContents.send("SKYWORK-TOKENS", { inviteToken, token });
} else if (url.startsWith("https://character.ai/")) {
const token = await getLocalStorage("char_token");
mainWindow.webContents.send("CHARACTER-AI-TOKENS", token);
} else if (url.startsWith("https://claude.ai/")) {
const org = await getLocalStorage("lastActiveOrg");
mainWindow.webContents.send("CLAUDE-2-ORG", org);
} else if (url.startsWith("https://poe.com/")) {
const formkey = await newWin.webContents.executeJavaScript(
"window.ereNdsRqhp2Rd3LEW();",
);
mainWindow.webContents.send("POE-FORMKEY", formkey);
try {
// Hacking secrets
const getLocalStorage = async (key) => {
return await newWin.webContents.executeJavaScript(
`localStorage.getItem("${key}");`,
);
};
if (url.startsWith("https://moss.fastnlp.top/")) {
// Get the secret of MOSS
const secret = await getLocalStorage("flutter.token");
mainWindow.webContents.send("moss-secret", secret);
} else if (url.startsWith("https://qianwen.aliyun.com/")) {
// Get QianWen bot's XSRF-TOKEN
const token = await newWin.webContents.executeJavaScript(
'document.cookie.split("; ").find((cookie) => cookie.startsWith("XSRF-TOKEN="))?.split("=")[1];',
);
mainWindow.webContents.send("QIANWEN-XSRF-TOKEN", token);
} else if (url.startsWith("https://neice.tiangong.cn/")) {
// Get the tokens of SkyWork
const inviteToken = await getLocalStorage("formNatureQueueWaitToken");
const token = await getLocalStorage("formNatureResearchToken");
mainWindow.webContents.send("SKYWORK-TOKENS", { inviteToken, token });
} else if (url.startsWith("https://character.ai/")) {
const token = await getLocalStorage("char_token");
mainWindow.webContents.send("CHARACTER-AI-TOKENS", token);
} else if (url.startsWith("https://claude.ai/")) {
const org = await getLocalStorage("lastActiveOrg");
mainWindow.webContents.send("CLAUDE-2-ORG", org);
} else if (url.startsWith("https://poe.com/")) {
const formkey = await newWin.webContents.executeJavaScript(
"window.ereNdsRqhp2Rd3LEW();",
);
mainWindow.webContents.send("POE-FORMKEY", formkey);
}
} catch (err) {
console.error(err);
}

newWin.destroy(); // Destroy the window manually
Expand Down

1 comment on commit 7916d25

@vercel
Copy link

@vercel vercel bot commented on 7916d25 Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

chatall – ./

chatall-llm.vercel.app
chatall-sunner.vercel.app
chatall-git-main-sunner.vercel.app

Please sign in to comment.