Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix login/blank splash problem #317

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ const createWindow = () => {
mainWindow.reload()
},
},
{
label: 'Login',
visible: parameters.selectionText.trim().length === 0,
click: () => {
mainWindow.loadURL(`https://www.bing.com/fd/auth/signin?action=interactive&provider=windows_live_id&return_url=https%3a%2f%2fwww.bing.com`)
},
},
{
label: 'Return To GPT',
visible: parameters.selectionText.trim().length === 0,
click: () => {
mainWindow.loadURL(`https://edgeservices.bing.com/edgediscover/query?&${
isDarkMode ? 'dark' : 'light'
}schemeovr=1&FORM=SHORUN&udscs=1&udsnav=1&setlang=${locale}&features=udssydinternal&clientscopes=windowheader,coauthor,chat,&udsframed=1`)
},
},
{
label: 'Export',
visible: parameters.selectionText.trim().length === 0,
Expand Down Expand Up @@ -227,6 +243,9 @@ const createWindow = () => {
isDarkMode ? 'dark' : 'light'
}schemeovr=1&FORM=SHORUN&udscs=1&udsnav=1&setlang=${locale}&features=udssydinternal&clientscopes=windowheader,coauthor,chat,&udsframed=1`
mainWindow.loadURL(bingUrl)

// mainWindow.webContents.openDevTools();

// Open links in default browser
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
shell.openExternal(url)
Expand Down Expand Up @@ -353,12 +372,20 @@ const createWindow = () => {
}
}
})
// Replace compose page
// Replace compose page or reload window
mainWindow.webContents.on('dom-ready', () => {
const url = mainWindow.webContents.getURL()
if (url === bingUrl) {
mainWindow.webContents.send('replace-compose-page', isDarkMode)
}

// console.log(url);
if (url === "https://www.bing.com/") {
setTimeout(() => {
mainWindow.loadURL(bingUrl);
}, 3000);
}

})
}

Expand Down
22 changes: 21 additions & 1 deletion preload.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ipcRenderer } = require('electron')
const { ipcRenderer, app, nativeTheme} = require('electron')
const html2canvas = require('html2canvas')
const { jsPDF } = require('jspdf')
const TurndownService = require('turndown')
Expand All @@ -17,6 +17,26 @@ window.addEventListener('DOMContentLoaded', () => {
'position: fixed; top: 0px; height: 32px; width: 100%; -webkit-user-select: none; -webkit-app-region: drag; z-index: 50'
body.prepend(titleBar)
}

//Login Check
const isLoginedIn = document.getElementById('underside-sydney-module') != null;
// console.log(isLoginedIn);
if (!isLoginedIn) {
const content = document.getElementById('b_content')

const error_login = document.createElement("p");

error_login.style.cssText="display: flex; flex-direction: column; justify-content: center; align-items: center; position: absolute; width: 100vw; height: 100vh; top: 0; left: 0;"

const image = require('electron').nativeImage.createFromPath('icon.png')

error_login.innerHTML = `<a href='https://www.bing.com/fd/auth/signin?action=interactive&provider=windows_live_id&return_url=https%3a%2f%2fwww.bing.com'><img alt="login" width="200px" height="200px" src='${image.toDataURL()}'></a>` +
"<h1 style='margin-bottom: 10px; font-size: 40px; text-align: center;'>Login Needed!</h1>" +
"<a style='display: block; margin-top: 10px; font-size: 25px; text-align: center;' href='https://www.bing.com/fd/auth/signin?action=interactive&provider=windows_live_id&return_url=https%3a%2f%2fwww.bing.com'>Login</a>"

content.appendChild(error_login);
}

// Content
const content = document.getElementById('b_content')
if (content) {
Expand Down