refac: make application more lean and Akarton specific
All checks were successful
Build/release / action-release (push) Successful in 4m15s

This commit is contained in:
2025-09-30 11:55:20 +02:00
parent b5ec8edbd4
commit f664c94032
5 changed files with 22 additions and 184 deletions

View File

@@ -3,7 +3,7 @@ import { getValue, setValue } from "./store.js";
import { ElectronBlocker } from "@ghostery/adblocker-electron";
import prompt from "electron-prompt";
import { getScreenWidth, getScreenHeight } from "./dimensions.js";
//import { getScreenWidth, getScreenHeight } from "./dimensions.js";
import { setUserAgent } from "./utils.js";
import useragents from "../useragents.json" with { type: "json" };
@@ -197,71 +197,6 @@ const commonPreferencesSubmenu = [
},
],
},
{
label: "Custom Home Page",
submenu: [
{
label: "Home (Default)",
type: "radio",
click: () => {
setValue("custompage", "home");
dialog.showMessageBoxSync({
type: "info",
title: "Custom Home Page",
message:
"You have set the home page to the default home page. Please restart the app to apply the changes.",
buttons: ["OK"],
});
},
checked: getValue("custompage") === "home",
},
{
label: "Create",
type: "radio",
click: () => {
setValue("custompage", "create");
dialog.showMessageBoxSync({
type: "info",
title: "Custom Home Page",
message:
'You have set the home page to the "Create" page. Please restart the app to apply the changes.',
buttons: ["OK"],
});
},
checked: getValue("custompage") === "create",
},
{
label: "My Content",
type: "radio",
click: () => {
setValue("custompage", "mycontent");
dialog.showMessageBoxSync({
type: "info",
title: "Custom Home Page",
message:
'You have set the home page to the "My Content" page. Please restart the app to apply the changes.',
buttons: ["OK"],
});
},
checked: getValue("custompage") === "mycontent",
},
{
label: "Apps",
type: "radio",
click: () => {
setValue("custompage", "apps");
dialog.showMessageBoxSync({
type: "info",
title: "Custom Home Page",
message:
'You have set the home page to the "Apps" page. Please restart the app to apply the changes.',
buttons: ["OK"],
});
},
checked: getValue("custompage") === "apps",
},
],
},
{ type: "separator" },
{
label: "Enable Auto Updates",
@@ -364,12 +299,20 @@ const commonPreferencesSubmenu = [
},
{ type: "separator" },
{
label: "Windows User-Agent String",
label: "Windows Chrome User-Agent String",
type: "radio",
click: () => {
setUserAgent(useragents.Windows);
setUserAgent(useragents.WindowsChrome);
},
checked: getValue("useragentstring") === useragents.Windows,
checked: getValue("useragentstring") === useragents.WindowsChrome,
},
{
label: "Windows Firefox User-Agent String",
type: "radio",
click: () => {
setUserAgent(useragents.WindowsFirefox);
},
checked: getValue("useragentstring") === useragents.WindowsFirefox,
},
{
label: "macOS User-Agent String",
@@ -430,46 +373,6 @@ const menulayout = [
]),
],
},
{
label: "File",
submenu: [
{
label: "Close Window",
accelerator: "CmdOrCtrl+W",
click: () => {
try {
BrowserWindow.getFocusedWindow().close();
} catch {
return;
}
},
},
{
label: "Close All Windows",
accelerator: "CmdOrCtrl+Shift+W",
click: () => {
BrowserWindow.getAllWindows().forEach((window) => {
window.close();
});
},
},
{ type: "separator" },
...(process.platform === "darwin"
? [
{
label: "Share...",
click: () => {
let sharemenu = new ShareMenu({
urls: [BrowserWindow.getFocusedWindow().webContents.getURL()],
texts: [BrowserWindow.getFocusedWindow().getTitle()],
});
sharemenu.popup();
},
},
]
: []),
],
},
{
label: "Edit",
submenu: [
@@ -543,74 +446,6 @@ const menulayout = [
{ role: "togglefullscreen" },
],
},
{
label: "Apps",
submenu: [
{
label: "Word",
click: () => {
if (getValue("websites-in-new-window") === "true") {
let wordwindow = new BrowserWindow({
width: Math.round(getScreenWidth() * (getValue("windowWidth") - 0.07)),
height: Math.round(getScreenHeight() * (getValue("windowHeight") - 0.07)),
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
partition: "persist:work",
},
});
wordwindow.loadURL("https://microsoft365.com/launch/word?auth=2");
} else {
BrowserWindow.getFocusedWindow().loadURL(
"https://microsoft365.com/launch/word?auth=2"
);
}
},
},
{
label: "Excel",
click: () => {
if (getValue("websites-in-new-window") === "true") {
let excelwindow = new BrowserWindow({
width: Math.round(getScreenWidth() * (getValue("windowWidth") - 0.07)),
height: Math.round(getScreenHeight() * (getValue("windowHeight") - 0.07)),
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
partition: "persist:work",
},
});
excelwindow.loadURL("https://microsoft365.com/launch/excel?auth=2");
} else {
BrowserWindow.getFocusedWindow().loadURL(
"https://microsoft365.com/launch/excel?auth=2"
);
}
},
},
{
label: "PowerPoint",
click: () => {
if (getValue("websites-in-new-window") === "true") {
let powerpointwindow = new BrowserWindow({
width: Math.round(getScreenWidth() * (getValue("windowWidth") - 0.07)),
height: Math.round(getScreenHeight() * (getValue("windowHeight") - 0.07)),
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
partition: "persist:work",
},
});
powerpointwindow.loadURL("https://microsoft365.com/launch/powerpoint?auth=2");
} else {
BrowserWindow.getFocusedWindow().loadURL(
"https://microsoft365.com/launch/powerpoint?auth=2"
);
}
},
},
],
},
{
label: "Window",
submenu: [

View File

@@ -22,7 +22,7 @@ export function getValueOrDefault(key, defaultValue) {
getValueOrDefault("enterprise-or-normal", "?auth=2");
getValueOrDefault("websites-in-new-window", "false");
getValueOrDefault("autohide-menubar", "false");
getValueOrDefault("autohide-menubar", "true");
getValueOrDefault("useragentstring", useragents.Windows);
getValueOrDefault("blockadsandtrackers", "false");
getValueOrDefault("dynamicicons", "true");

View File

@@ -122,4 +122,4 @@
"*.wus-firstpartyapps.oaspapps.com"
],
"source": "https://learn.microsoft.com/en-us/microsoft-365/enterprise/urls-and-ip-address-ranges?view=o365-worldwide"
}
}

View File

@@ -54,7 +54,9 @@ function createWindow() {
splash.loadURL(`https://agam778.github.io/MS-365-Electron/loading`);
win.loadURL(`https://microsoft365.com/${custompage}/${enterpriseOrNormal}`, {
//The following line is regarding the starting page.
//The default is: https://microsoft365.com/${custompage}/${enterpriseOrNormal}
win.loadURL(`https://akartonbv.sharepoint.com/:x:/r/sites/Bedrijfsbureau/_layouts/15/Doc.aspx?sourcedoc=%7BB0980620-EBBB-474A-AF4B-44DA45132A9C%7D&file=Productieplanning%20OneDrive.xlsx&action=default&mobileredirect=true`, {
userAgent: getValue("useragentstring") || Windows,
});

View File

@@ -1,5 +1,6 @@
{
"Windows": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
"macOS": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
"Linux": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
}
"WindowsChrome": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36",
"WindowsFirefox": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:143.0) Gecko/20100101 Firefox/143.0",
"macOS": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36",
"Linux": "Mozilla/5.0 (X11; Linux x86_64; rv:140.0) Gecko/20100101 Firefox/140.0"
}