Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Kadachigov committed Jan 19, 2024
2 parents 8cf187f + 0a028c3 commit 01e7152
Show file tree
Hide file tree
Showing 10 changed files with 452 additions and 676 deletions.
1 change: 0 additions & 1 deletion app/app-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default class BrowserXAppMain extends EventEmitter {

initAppLifeCycle() {
app.on('ready', async () => {
enhanceSession(session.defaultSession);
// can register a onOpen function that should return a promise
if (typeof this.onOpen === 'function') {
await this.onOpen();
Expand Down
11 changes: 6 additions & 5 deletions app/services/services/tab-webcontents/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,12 @@ export class TabWebContentsServiceImpl extends TabWebContentsService implements
this.askAutoLogin.subscribe(async (webContentsId: number) => {
const wc = await getWebContentsFromIdOrThrow(webContentsId);

const { account, canAutoSubmit } = await provider.getCredentials(wc.id);
if (account) {
wc.focus();
wc.send('autologin-value-retrieved', account, canAutoSubmit);
}
// vk: 18.01.2024 FIXME: TypeError: Cannot destructure property 'account' of '(intermediate value)' as it is null.
// const { account, canAutoSubmit } = await provider.getCredentials(wc.id);
// if (account) {
// wc.focus();
// wc.send('autologin-value-retrieved', account, canAutoSubmit);
// }
}),
shared.subscribe(wc => {
return fromEvent(wc, 'ipc-message', (_e, channel) => channel)
Expand Down
15 changes: 9 additions & 6 deletions app/session.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import { Session, OnBeforeSendHeadersListenerDetails, OnHeadersReceivedListenerDetails,
HeadersReceivedResponse, BeforeSendResponse } from 'electron';
import { Session, OnBeforeSendHeadersListenerDetails, BeforeSendResponse } from 'electron';
import enhanceWebRequest from 'electron-better-web-request';

const defaultUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.5735.289 Safari/537.36';
const defaultUserAgent = 'Chrome/114.0.5735.289';

const getUserAgentForApp = (url: string, currentUserAgent: string): string => {

if (url.startsWith('file://') || url.startsWith('http://localhost')) {
return currentUserAgent;
}
else if (url.startsWith('https://accounts.google.com')) {
return 'Chrome/87.0.4280.141';
}

return defaultUserAgent;
};
Expand Down Expand Up @@ -53,6 +49,13 @@ export const enhanceSession = (session: Session) => {

session.setUserAgent(defaultUserAgent);

// session.webRequest.onBeforeRequest(
// (details: OnBeforeRequestListenerDetails, callback: (response: CallbackResponse) => void) => {
// console.log('AAAAAA', details.url, ' ||| ', session.getStoragePath());
// callback({ cancel: false });
// }
// );

session.webRequest.onBeforeSendHeaders(
(details: OnBeforeSendHeadersListenerDetails, callback: (beforeSendResponse: BeforeSendResponse) => void) => {
details.requestHeaders['User-Agent'] = getUserAgentForApp(details.url, session.getUserAgent());
Expand Down
2 changes: 1 addition & 1 deletion appstore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"typescript": "^3.9.4",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^4.15.1"
"webpack-dev-server": "^3.11.3"
},
"resolutions": {
"aws-sdk": "2.180.0"
Expand Down
Loading

0 comments on commit 01e7152

Please sign in to comment.