From 30f30c3e85f2b7932fd9af008e658326887a59a4 Mon Sep 17 00:00:00 2001 From: Antoine Guilbert Date: Wed, 19 Apr 2023 23:35:46 +0200 Subject: [PATCH] Update packages and fixes --- .github/workflows/build.yml | 4 ++-- main.js | 22 +++++++++++++++++++++- package.json | 23 ++++++++++++++++------- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2f6a47a..43f6c60 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,10 +17,10 @@ jobs: - name: Install Node.js, NPM and Yarn uses: actions/setup-node@v1 with: - node-version: 10 + node-version: 20 - name: Build/release Electron app - uses: samuelmeuli/action-electron-builder@v1 + uses: samuelmeuli/action-electron-builder@v1.6.0 with: # GitHub token, automatically provided to the action # (No need to define this secret in the repo settings) diff --git a/main.js b/main.js index dcc8a89..05d83b5 100644 --- a/main.js +++ b/main.js @@ -3,7 +3,7 @@ const electron = require('electron'); const path = require('path'); const url = require('url'); const windowStateKeeper = require('electron-window-state'); -const { app, BrowserWindow, Menu, MenuItem, dialog } = electron; +const { app, BrowserWindow, Menu, MenuItem, dialog, nativeTheme } = electron; const { autoUpdater } = require('electron-updater'); let mainWindow @@ -39,6 +39,20 @@ function createWindow () { mainWindow = new BrowserWindow(windowOptions) //mainWindow.webContents.openDevTools(); + // set user agent to potentially make google fi work + const userAgent = + "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0"; + +mainWindow.webContents.session.webRequest.onBeforeSendHeaders( + { + urls: ["https://accounts.google.com/*"], + }, + ({ requestHeaders }, callback) => + callback({ + requestHeaders: { ...requestHeaders, "User-Agent": userAgent }, + }) +); + mainWindow.loadURL(url.format({ pathname: path.join('messages.google.com/web'), protocol: 'https:', @@ -50,6 +64,12 @@ function createWindow () { electron.shell.openExternal(url); }) + nativeTheme.on('updated', () => { + mainWindow.webContents.send(EVENT_UPDATE_USER_SETTING, { + useDarkMode: nativeTheme.shouldUseDarkColors + }); + }); + //When a SMS arrived in the app, change the badge if (process.platform === 'darwin') { mainWindow.on('page-title-updated', function (e, title) { diff --git a/package.json b/package.json index 8b80e81..6a9ea12 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "android-messages", "productName": "Android Messages", "appId": "com.antoineguilbert.android-messages", - "version": "1.1.7", + "version": "2.0.0", "description": "Just a simple project made with electron JS to show Android Messages from Google in a app with notifications.", "main": "main.js", "scripts": { @@ -20,7 +20,15 @@ "build": { "appId": "com.antoineguilbert.android-messages", "mac": { - "category": "public.app-category.social-networking" + "category": "public.app-category.social-networking", + "target": [ + { + "target": "mas", + "arch": [ + "universal" + ] + } + ] }, "win": { "target": "nsis" @@ -41,13 +49,14 @@ ] }, "devDependencies": { - "electron": "^11.1.1", - "electron-builder": "^22.9.1" + "electron": "^24.1.2", + "electron-builder": "^24.2.1" }, "dependencies": { - "electron-context-menu": "^2.4.0", - "electron-updater": "^4.0.6", + "electron-context-menu": "^3.1.1", + "electron-updater": "^5.3.0", "electron-window-state": "^5.0.3", - "i18n": "^0.13.2" + "i18n": "^0.15.1", + "latest-version": "^7.0.0" } }