2023-06-05 20:12:06 +05:30
const useragents = require ( "./useragents.json" ) ;
2023-06-12 12:42:59 +05:30
const { app , dialog , BrowserWindow , ShareMenu } = require ( "electron" ) ;
2023-06-05 20:12:06 +05:30
const axios = require ( "axios" ) ;
2023-06-09 17:04:37 +05:30
const { clearActivity , setActivity } = require ( "./rpc" ) ;
2023-06-09 22:09:31 +05:30
const { shell } = require ( "electron" ) ;
const { autoUpdater } = require ( "electron-updater" ) ;
2023-06-10 01:24:08 +05:30
const { ElectronBlocker } = require ( "@cliqz/adblocker-electron" ) ;
const fetch = require ( "cross-fetch" ) ;
2023-06-11 18:16:30 +05:30
const openAboutWindow = require ( "about-window" ) . default ;
const path = require ( "path" ) ;
2023-06-11 21:15:36 +05:30
const { getValue , setValue , getValueOrDefault } = require ( "./store" ) ;
2023-06-05 20:12:06 +05:30
async function checkForUpdates ( ) {
try {
const res = await axios . get (
"https://api.github.com/repos/agam778/MS-365-Electron/releases/latest"
) ;
const data = res . data ;
const currentVersion = "v" + app . getVersion ( ) ;
const latestVersion = data . tag _name ;
if ( currentVersion !== latestVersion ) {
2023-06-09 22:09:31 +05:30
if ( process . platform === "win32" || process . platform === "darwin" ) {
autoUpdater . checkForUpdatesAndNotify ( ) . then ( ( result ) => {
if ( result === null ) {
dialog . showMessageBoxSync ( {
type : "info" ,
title : "No Update Available" ,
message : ` Current version: ${ currentVersion } \n Latest version: ${ latestVersion } \n \n You are already using the latest version. ` ,
buttons : [ "OK" ] ,
} ) ;
}
} ) ;
return ;
} else {
const updatedialog = dialog . showMessageBoxSync ( {
type : "info" ,
title : "Update Available" ,
message : ` Current version: ${ currentVersion } \n Latest version: ${ latestVersion } \n \n Please update to the latest version. ` ,
buttons : [ "Download" , "Close" ] ,
} ) ;
if ( updatedialog === 0 ) {
shell . openExternal (
"https://github.com/agam778/MS-365-Electron/releases/latest"
) ;
}
2023-06-05 20:12:06 +05:30
}
} else {
dialog . showMessageBoxSync ( {
type : "info" ,
title : "No Update Available" ,
message : ` Your App's version: ${ currentVersion } \n Latest version: ${ latestVersion } \n \n You are already using the latest version. ` ,
buttons : [ "OK" ] ,
} ) ;
}
} catch ( error ) {
console . error ( "Error checking for updates:" , error ) ;
}
}
async function openExternalLink ( url ) {
const { shell } = require ( "electron" ) ;
await shell . openExternal ( url ) ;
}
async function openLogsFolder ( ) {
const { shell } = require ( "electron" ) ;
if ( process . platform === "win32" ) {
await shell . openPath (
"C:\\Users\\" +
process . env . USERNAME +
"\\AppData\\Roaming\\ms-365-electron\\logs\\"
) ;
} else if ( process . platform === "darwin" ) {
await shell . openPath (
"/Users/" + process . env . USER + "/Library/Logs/ms-365-electron/"
) ;
} else if ( process . platform === "linux" ) {
await shell . openPath (
"/home/" + process . env . USER + "/.config/ms-365-electron/logs/"
) ;
}
}
function setUserAgent ( useragent ) {
2023-06-11 21:15:36 +05:30
setValue ( "useragentstring" , useragent ) ;
2023-06-05 20:12:06 +05:30
const updatedialog = dialog . showMessageBoxSync ( {
type : "info" ,
title : "User-Agent string changed" ,
message : ` You have switched to the ${ useragent } User-Agent string. \n \n Please restart the app for the changes to take effect. ` ,
buttons : [ "Later" , "Restart" ] ,
} ) ;
if ( updatedialog === 1 ) {
app . relaunch ( ) ;
app . exit ( ) ;
}
}
getValueOrDefault ( "enterprise-or-normal" , "https://microsoft365.com/?auth=1" ) ;
getValueOrDefault ( "autohide-menubar" , "false" ) ;
getValueOrDefault ( "useragentstring" , useragents . Windows ) ;
2023-06-09 17:04:37 +05:30
getValueOrDefault ( "discordrpcstatus" , "false" ) ;
2023-06-10 01:24:08 +05:30
getValueOrDefault ( "blockadsandtrackers" , "false" ) ;
2023-06-11 23:20:17 +05:30
getValueOrDefault ( "dynamicicons" , "true" ) ;
2023-06-12 00:49:47 +05:30
getValueOrDefault ( "autoupdater" , "true" ) ;
2023-06-05 20:12:06 +05:30
const menulayout = [
2023-06-09 22:08:30 +05:30
... ( process . platform === "darwin"
? [
{
label : app . name ,
submenu : [
2023-06-11 18:16:30 +05:30
{
label : "About MS-365-Electron" ,
click : ( ) => {
openAboutWindow ( {
icon _path : path . join ( _ _dirname , "../assets/about.png" ) ,
product _name : "MS-365-Electron" ,
copyright :
"Copyright (c) 2021-2023 Agampreet Singh\nMicrosoft 365, the name, website, images/icons\nare the intellectual properties of Microsoft." ,
package _json _dir : _ _dirname + "/../" ,
bug _report _url :
"https://github.com/agam778/MS-365-Electron/issues/" ,
bug _link _text : "Report an issue" ,
adjust _window _size : "2" ,
show _close _button : "Close" ,
} ) ;
} ,
} ,
2023-06-09 22:08:30 +05:30
{
2023-06-12 00:35:08 +05:30
label : "Check for Updates" ,
id : "check-for-updates" ,
2023-06-09 22:08:30 +05:30
click : async ( ) => {
2023-06-12 00:35:08 +05:30
await checkForUpdates ( ) ;
2023-06-09 22:08:30 +05:30
} ,
} ,
2023-06-12 00:35:08 +05:30
{ type : "separator" } ,
2023-06-09 22:08:30 +05:30
{
2023-06-12 00:35:08 +05:30
label : "Learn More" ,
2023-06-09 22:08:30 +05:30
click : async ( ) => {
2023-06-12 00:35:08 +05:30
await openExternalLink (
"https://github.com/agam778/MS-365-Electron"
) ;
2023-06-09 22:08:30 +05:30
} ,
} ,
{
label : "Open Logs Folder" ,
click : async ( ) => {
await openLogsFolder ( ) ;
} ,
} ,
{ type : "separator" } ,
2023-06-12 12:42:59 +05:30
{
label : "Preferences" ,
submenu : [
{
label : "Open Normal version of MS 365" ,
type : "radio" ,
click ( ) {
setValue (
"enterprise-or-normal" ,
"https://microsoft365.com/?auth=1"
) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Normal version of MS 365" ,
message :
"The normal version of MS 365 will be opened.\n\nPlease restart the app to apply the changes." ,
buttons : [ "OK" ] ,
} ) ;
} ,
checked :
getValue ( "enterprise-or-normal" ) ===
"https://microsoft365.com/?auth=1" ,
} ,
{
label : "Open Enterprise version of MS 365" ,
type : "radio" ,
click ( ) {
setValue (
"enterprise-or-normal" ,
"https://microsoft365.com/?auth=2"
) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Enterprise version of MS 365" ,
message :
"The enterprise version of MS 365 will be opened.\n\nPlease restart the app to apply the changes." ,
buttons : [ "OK" ] ,
} ) ;
} ,
checked :
getValue ( "enterprise-or-normal" ) ===
"https://microsoft365.com/?auth=2" ,
} ,
{ type : "separator" } ,
{
label : "Open Websites in New Windows (Recommended)" ,
type : "radio" ,
click : ( ) => {
setValue ( "websites-in-new-window" , "true" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Websites in New Windows" ,
message :
"Websites which are targeted to open in new tabs will now open in new windows." ,
buttons : [ "OK" ] ,
} ) ;
} ,
checked : getValue ( "websites-in-new-window" )
? getValue ( "websites-in-new-window" ) === "true"
: true ,
} ,
{
label : "Open Websites in the Same Window" ,
type : "radio" ,
click : ( ) => {
setValue ( "websites-in-new-window" , "false" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Websites in New Windows" ,
message :
"Websites which are targeted to open in new tabs will now open in the same window.\n\nNote: This will be buggy in some cases if you are using Enterprise version of MS 365." ,
buttons : [ "OK" ] ,
} ) ;
} ,
checked : getValue ( "websites-in-new-window" )
? getValue ( "websites-in-new-window" ) === "false"
: false ,
} ,
{ type : "separator" } ,
{
label : "Enable Discord RPC" ,
type : "checkbox" ,
click : ( ) => {
if ( getValue ( "discordrpcstatus" ) === "true" ) {
setValue ( "discordrpcstatus" , "false" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Discord RPC" ,
message : "Discord RPC has been disabled." ,
buttons : [ "OK" ] ,
} ) ;
clearActivity ( ) ;
return ;
} else if (
getValue ( "discordrpcstatus" ) === "false" ||
getValue ( "discordrpcstatus" ) === undefined
) {
setValue ( "discordrpcstatus" , "true" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Discord RPC" ,
message : "Discord RPC has been enabled." ,
buttons : [ "OK" ] ,
} ) ;
setActivity (
` On ${ BrowserWindow . getFocusedWindow ( ) . webContents . getTitle ( ) } `
) ;
return ;
}
} ,
checked : getValue ( "discordrpcstatus" ) === "true" ,
} ,
{
label : "Enable Auto Updates" ,
type : "checkbox" ,
click : ( ) => {
if ( getValue ( "autoupdater" ) === "true" ) {
setValue ( "autoupdater" , "false" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Auto Updates" ,
message : "Auto updates have been disabled." ,
buttons : [ "OK" ] ,
} ) ;
return ;
} else if (
getValue ( "autoupdater" ) === "false" ||
getValue ( "autoupdater" ) === undefined
) {
setValue ( "autoupdater" , "true" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Auto Updates" ,
message : "Auto updates have been enabled." ,
buttons : [ "OK" ] ,
} ) ;
return ;
}
} ,
checked : getValue ( "autoupdater" ) === "true" ,
} ,
{
label : "Enable Dynamic Icons" ,
type : "checkbox" ,
click : ( ) => {
if ( getValue ( "dynamicicons" ) === "true" ) {
setValue ( "dynamicicons" , "false" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Dynamic Icons" ,
message : "Dynamic icons have been disabled." ,
buttons : [ "OK" ] ,
} ) ;
return ;
} else if (
getValue ( "dynamicicons" ) === "false" ||
getValue ( "dynamicicons" ) === undefined
) {
setValue ( "dynamicicons" , "true" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Dynamic Icons" ,
message : "Dynamic icons have been enabled." ,
buttons : [ "OK" ] ,
} ) ;
return ;
}
} ,
checked : getValue ( "dynamicicons" ) === "true" ,
} ,
{ type : "separator" } ,
{
label : "Block Ads and Trackers" ,
type : "checkbox" ,
click : ( ) => {
if ( getValue ( "blockadsandtrackers" ) === "true" ) {
setValue ( "blockadsandtrackers" , "false" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Block Ads and Trackers" ,
message : "Ads and trackers will no longer be blocked." ,
buttons : [ "OK" ] ,
} ) ;
ElectronBlocker . fromPrebuiltAdsAndTracking ( fetch ) . then (
( blocker ) => {
blocker . disableBlockingInSession (
BrowserWindow . getFocusedWindow ( ) . webContents . session
) ;
}
) ;
return ;
}
if (
getValue ( "blockadsandtrackers" ) === "false" ||
getValue ( "blockadsandtrackers" ) === undefined
) {
setValue ( "blockadsandtrackers" , "true" ) ;
ElectronBlocker . fromPrebuiltAdsAndTracking ( fetch ) . then (
( blocker ) => {
blocker . enableBlockingInSession (
BrowserWindow . getFocusedWindow ( ) . webContents . session
) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Block Ads and Trackers" ,
message : "Ads and trackers will now be blocked." ,
buttons : [ "OK" ] ,
} ) ;
}
) ;
return ;
}
} ,
checked : getValue ( "blockadsandtrackers" ) === "true" ,
} ,
{ type : "separator" } ,
{
label : "Windows User-Agent String" ,
type : "radio" ,
click : ( ) => {
setUserAgent ( useragents . Windows ) ;
} ,
checked : getValue ( "useragentstring" ) === useragents . Windows ,
} ,
{
label : "macOS User-Agent String" ,
type : "radio" ,
click : ( ) => {
setUserAgent ( useragents . macOS ) ;
} ,
checked : getValue ( "useragentstring" ) === useragents . macOS ,
} ,
{
label : "Linux User-Agent String" ,
type : "radio" ,
click : ( ) => {
setValue ( "useragentstring" , useragents . Linux ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "User agent switcher" ,
message :
"You have switched to Linux Useragent.\n\nPlease restart the app to apply the changes." ,
buttons : [ "OK" ] ,
} ) ;
} ,
checked : getValue ( "useragentstring" ) === useragents . Linux ,
} ,
{ type : "separator" } ,
... ( ! process . platform === "darwin"
? [
{
role : "quit" ,
accelerator : "Ctrl+Q" ,
} ,
]
: [ ] ) ,
] ,
} ,
2023-06-09 22:08:30 +05:30
{ role : "services" } ,
{ type : "separator" } ,
{ label : "Hide MS-365-Electron" , role : "hide" } ,
{ role : "hideOthers" } ,
{ role : "unhide" } ,
{ type : "separator" } ,
{ label : "Quit MS-365-Electron" , role : "quit" } ,
] ,
} ,
]
: [ ] ) ,
2023-06-05 20:12:06 +05:30
{
2023-06-12 12:42:59 +05:30
label : "File" ,
2023-06-05 20:12:06 +05:30
submenu : [
{
2023-06-12 12:42:59 +05:30
label : "New Window" ,
accelerator : "CmdOrCtrl+N" ,
click : ( ) => {
let newWindow = new BrowserWindow ( {
width : 1181 ,
height : 670 ,
webPreferences : {
nodeIntegration : true ,
devTools : true ,
} ,
2023-06-05 20:12:06 +05:30
} ) ;
2023-06-12 12:42:59 +05:30
newWindow . loadURL ( getValue ( "enterprise-or-normal" ) ) ;
2023-06-05 20:12:06 +05:30
} ,
} ,
{ type : "separator" } ,
{
2023-06-12 12:42:59 +05:30
label : "Close Window" ,
accelerator : "CmdOrCtrl+W" ,
2023-06-05 20:12:06 +05:30
click : ( ) => {
2023-06-12 12:42:59 +05:30
BrowserWindow . getFocusedWindow ( ) . close ( ) ;
2023-06-05 20:12:06 +05:30
} ,
} ,
{
2023-06-12 12:42:59 +05:30
label : "Close All Windows" ,
accelerator : "CmdOrCtrl+Shift+W" ,
2023-06-05 20:12:06 +05:30
click : ( ) => {
2023-06-12 12:42:59 +05:30
BrowserWindow . getAllWindows ( ) . forEach ( ( window ) => {
window . close ( ) ;
2023-06-05 20:12:06 +05:30
} ) ;
} ,
} ,
{ type : "separator" } ,
2023-06-09 17:04:37 +05:30
{
2023-06-12 12:42:59 +05:30
label : "Share..." ,
2023-06-12 00:49:47 +05:30
click : ( ) => {
2023-06-12 12:42:59 +05:30
let sharemenu = new ShareMenu ( {
urls : [ BrowserWindow . getFocusedWindow ( ) . webContents . getURL ( ) ] ,
texts : [ BrowserWindow . getFocusedWindow ( ) . getTitle ( ) ] ,
} ) ;
sharemenu . popup ( ) ;
2023-06-11 23:20:17 +05:30
} ,
} ,
2023-06-12 12:42:59 +05:30
] ,
... ( process . platform === "win32" || process . platform === "linux"
? {
label :
process . platform === "darwin" ? "Preferences" : "MS-365-Electron" ,
submenu : [
... ( ! process . platform === "darwin"
? [
{
label : "About MS-365-Electron" ,
click : ( ) => {
openAboutWindow ( {
icon _path : path . join ( _ _dirname , "../assets/about.png" ) ,
product _name : "MS-365-Electron" ,
copyright :
"Copyright (c) 2021-2023 Agampreet Singh\nMicrosoft 365, the name, website, images/icons\nare the intellectual properties of Microsoft." ,
package _json _dir : _ _dirname + "/../" ,
bug _report _url :
"https://github.com/agam778/MS-365-Electron/issues/" ,
bug _link _text : "Report an issue" ,
adjust _window _size : "2" ,
show _close _button : "Close" ,
} ) ;
} ,
} ,
]
: [ ] ) ,
... ( ! process . platform === "darwin"
? [
{
label : "Check for Updates..." ,
id : "check-for-updates" ,
click : async ( ) => {
await checkForUpdates ( ) ;
} ,
} ,
]
: [ ] ) ,
... ( ! process . platform === "darwin" ? [ { type : "separator" } ] : [ ] ) ,
... ( ! process . platform === "darwin"
? [
{
label : "Learn More" ,
click : async ( ) => {
await openExternalLink (
"https://github.com/agam778/MS-365-Electron"
) ;
} ,
} ,
]
: [ ] ) ,
... ( ! process . platform === "darwin"
? [
{
label : "Open Logs Folder" ,
click : async ( ) => {
await openLogsFolder ( ) ;
} ,
} ,
]
: [ ] ) ,
{ type : "separator" } ,
{
label : "Open Normal version of MS 365" ,
type : "radio" ,
click ( ) {
setValue (
"enterprise-or-normal" ,
"https://microsoft365.com/?auth=1"
2023-06-11 22:50:00 +05:30
) ;
2023-06-12 12:42:59 +05:30
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Normal version of MS 365" ,
message :
"The normal version of MS 365 will be opened.\n\nPlease restart the app to apply the changes." ,
buttons : [ "OK" ] ,
} ) ;
} ,
checked :
getValue ( "enterprise-or-normal" ) ===
"https://microsoft365.com/?auth=1" ,
} ,
{
label : "Open Enterprise version of MS 365" ,
type : "radio" ,
click ( ) {
setValue (
"enterprise-or-normal" ,
"https://microsoft365.com/?auth=2"
2023-06-10 01:24:08 +05:30
) ;
dialog . showMessageBoxSync ( {
type : "info" ,
2023-06-12 12:42:59 +05:30
title : "Enterprise version of MS 365" ,
message :
"The enterprise version of MS 365 will be opened.\n\nPlease restart the app to apply the changes." ,
2023-06-10 01:24:08 +05:30
buttons : [ "OK" ] ,
} ) ;
2023-06-12 12:42:59 +05:30
} ,
checked :
getValue ( "enterprise-or-normal" ) ===
"https://microsoft365.com/?auth=2" ,
} ,
{ type : "separator" } ,
{
label : "Open Websites in New Windows (Recommended)" ,
type : "radio" ,
click : ( ) => {
setValue ( "websites-in-new-window" , "true" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Websites in New Windows" ,
message :
"Websites which are targeted to open in new tabs will now open in new windows." ,
buttons : [ "OK" ] ,
} ) ;
} ,
checked : getValue ( "websites-in-new-window" )
? getValue ( "websites-in-new-window" ) === "true"
: true ,
} ,
{
label : "Open Websites in the Same Window" ,
type : "radio" ,
click : ( ) => {
setValue ( "websites-in-new-window" , "false" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Websites in New Windows" ,
message :
"Websites which are targeted to open in new tabs will now open in the same window.\n\nNote: This will be buggy in some cases if you are using Enterprise version of MS 365." ,
buttons : [ "OK" ] ,
} ) ;
} ,
checked : getValue ( "websites-in-new-window" )
? getValue ( "websites-in-new-window" ) === "false"
: false ,
} ,
{ type : "separator" } ,
{
label : "Enable Discord RPC" ,
type : "checkbox" ,
click : ( ) => {
if ( getValue ( "discordrpcstatus" ) === "true" ) {
setValue ( "discordrpcstatus" , "false" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Discord RPC" ,
message : "Discord RPC has been disabled." ,
buttons : [ "OK" ] ,
} ) ;
clearActivity ( ) ;
return ;
} else if (
getValue ( "discordrpcstatus" ) === "false" ||
getValue ( "discordrpcstatus" ) === undefined
) {
setValue ( "discordrpcstatus" , "true" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Discord RPC" ,
message : "Discord RPC has been enabled." ,
buttons : [ "OK" ] ,
} ) ;
setActivity (
` On ${ BrowserWindow . getFocusedWindow ( ) . webContents . getTitle ( ) } `
) ;
return ;
}
} ,
checked : getValue ( "discordrpcstatus" ) === "true" ,
} ,
{
label : "Enable Auto Updates" ,
type : "checkbox" ,
click : ( ) => {
if ( getValue ( "autoupdater" ) === "true" ) {
setValue ( "autoupdater" , "false" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Auto Updates" ,
message : "Auto updates have been disabled." ,
buttons : [ "OK" ] ,
} ) ;
return ;
} else if (
getValue ( "autoupdater" ) === "false" ||
getValue ( "autoupdater" ) === undefined
) {
setValue ( "autoupdater" , "true" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Auto Updates" ,
message : "Auto updates have been enabled." ,
buttons : [ "OK" ] ,
} ) ;
return ;
}
} ,
checked : getValue ( "autoupdater" ) === "true" ,
} ,
{
label : "Enable Dynamic Icons" ,
type : "checkbox" ,
click : ( ) => {
if ( getValue ( "dynamicicons" ) === "true" ) {
setValue ( "dynamicicons" , "false" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Dynamic Icons" ,
message : "Dynamic icons have been disabled." ,
buttons : [ "OK" ] ,
} ) ;
return ;
} else if (
getValue ( "dynamicicons" ) === "false" ||
getValue ( "dynamicicons" ) === undefined
) {
setValue ( "dynamicicons" , "true" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Dynamic Icons" ,
message : "Dynamic icons have been enabled." ,
buttons : [ "OK" ] ,
} ) ;
return ;
}
} ,
checked : getValue ( "dynamicicons" ) === "true" ,
} ,
{ type : "separator" } ,
{
label : "Block Ads and Trackers" ,
type : "checkbox" ,
click : ( ) => {
if ( getValue ( "blockadsandtrackers" ) === "true" ) {
setValue ( "blockadsandtrackers" , "false" ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Block Ads and Trackers" ,
message : "Ads and trackers will no longer be blocked." ,
buttons : [ "OK" ] ,
} ) ;
ElectronBlocker . fromPrebuiltAdsAndTracking ( fetch ) . then (
( blocker ) => {
blocker . disableBlockingInSession (
BrowserWindow . getFocusedWindow ( ) . webContents . session
) ;
}
) ;
return ;
}
if (
getValue ( "blockadsandtrackers" ) === "false" ||
getValue ( "blockadsandtrackers" ) === undefined
) {
setValue ( "blockadsandtrackers" , "true" ) ;
ElectronBlocker . fromPrebuiltAdsAndTracking ( fetch ) . then (
( blocker ) => {
blocker . enableBlockingInSession (
BrowserWindow . getFocusedWindow ( ) . webContents . session
) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Block Ads and Trackers" ,
message : "Ads and trackers will now be blocked." ,
buttons : [ "OK" ] ,
} ) ;
}
) ;
return ;
}
} ,
checked : getValue ( "blockadsandtrackers" ) === "true" ,
} ,
{ type : "separator" } ,
{
label : "Windows User-Agent String" ,
type : "radio" ,
click : ( ) => {
setUserAgent ( useragents . Windows ) ;
} ,
checked : getValue ( "useragentstring" ) === useragents . Windows ,
} ,
{
label : "macOS User-Agent String" ,
type : "radio" ,
click : ( ) => {
setUserAgent ( useragents . macOS ) ;
} ,
checked : getValue ( "useragentstring" ) === useragents . macOS ,
} ,
{
label : "Linux User-Agent String" ,
type : "radio" ,
click : ( ) => {
setValue ( "useragentstring" , useragents . Linux ) ;
dialog . showMessageBoxSync ( {
type : "info" ,
title : "User agent switcher" ,
message :
"You have switched to Linux Useragent.\n\nPlease restart the app to apply the changes." ,
buttons : [ "OK" ] ,
} ) ;
} ,
checked : getValue ( "useragentstring" ) === useragents . Linux ,
} ,
{ type : "separator" } ,
... ( ! process . platform === "darwin"
? [
{
role : "quit" ,
accelerator : "Ctrl+Q" ,
} ,
]
: [ ] ) ,
] ,
}
: { } ) ,
} ,
{
label : "Edit" ,
submenu : [
{ role : "undo" } ,
{ role : "redo" } ,
{ type : "separator" } ,
{ role : "cut" } ,
{ role : "copy" } ,
{ role : "paste" } ,
... ( process . platform === "darwin"
? [
{ role : "pasteAndMatchStyle" } ,
{ role : "delete" } ,
{ role : "selectAll" } ,
{ type : "separator" } ,
{
label : "Speech" ,
submenu : [ { role : "startSpeaking" } , { role : "stopSpeaking" } ] ,
} ,
]
: [ { role : "delete" } , { type : "separator" } , { role : "selectAll" } ] ) ,
] ,
} ,
{
label : "Navigation" ,
submenu : [
{
label : "Back" ,
click : ( ) => {
BrowserWindow . getFocusedWindow ( ) . webContents . goBack ( ) ;
2023-06-10 01:24:08 +05:30
} ,
2023-06-12 12:42:59 +05:30
accelerator : "Alt+Left" ,
2023-06-10 01:24:08 +05:30
} ,
2023-06-05 20:12:06 +05:30
{
2023-06-12 12:42:59 +05:30
label : "Forward" ,
2023-06-05 20:12:06 +05:30
click : ( ) => {
2023-06-12 12:42:59 +05:30
BrowserWindow . getFocusedWindow ( ) . webContents . goForward ( ) ;
2023-06-05 20:12:06 +05:30
} ,
2023-06-12 12:42:59 +05:30
accelerator : "Alt+Right" ,
2023-06-05 20:12:06 +05:30
} ,
{
2023-06-12 12:42:59 +05:30
label : "Reload" ,
2023-06-05 20:12:06 +05:30
click : ( ) => {
2023-06-12 12:42:59 +05:30
BrowserWindow . getFocusedWindow ( ) . webContents . reload ( ) ;
2023-06-05 20:12:06 +05:30
} ,
2023-06-12 12:42:59 +05:30
accelerator : "CmdOrCtrl+R" ,
2023-06-05 20:12:06 +05:30
} ,
{
2023-06-12 12:42:59 +05:30
label : "Home" ,
2023-06-05 20:12:06 +05:30
click : ( ) => {
2023-06-12 12:42:59 +05:30
BrowserWindow . getFocusedWindow ( ) . loadURL (
` ${ getValue ( "enterprise-or-normal" ) } `
) ;
2023-06-05 20:12:06 +05:30
} ,
} ,
2023-06-12 12:42:59 +05:30
] ,
} ,
{
label : "View" ,
submenu : [
{ role : "reload" } ,
{ role : "forceReload" } ,
2023-06-05 20:12:06 +05:30
{ type : "separator" } ,
2023-06-12 12:42:59 +05:30
{ role : "resetZoom" } ,
{
role : "zoomIn" ,
accelerator : process . platform === "darwin" ? "Control+=" : "Control+=" ,
} ,
{ role : "zoomOut" } ,
{ type : "separator" } ,
{ role : "togglefullscreen" } ,
2023-06-05 20:12:06 +05:30
] ,
} ,
2023-06-11 20:39:17 +05:30
{
label : "Apps" ,
submenu : [
{
label : "Word" ,
click : ( ) => {
if (
2023-06-11 21:15:36 +05:30
getValue ( "enterprise-or-normal" ) ===
2023-06-11 20:39:17 +05:30
"https://microsoft365.com/?auth=2"
) {
2023-06-11 21:15:36 +05:30
if ( getValue ( "websites-in-new-window" ) === "true" ) {
2023-06-11 20:39:17 +05:30
let wordwindow = new BrowserWindow ( {
width : 800 ,
height : 600 ,
webPreferences : {
nodeIntegration : false ,
contextIsolation : true ,
} ,
} ) ;
2023-06-11 21:00:20 +05:30
wordwindow . loadURL ( "https://microsoft365.com/launch/word?auth=2" ) ;
2023-06-11 20:39:17 +05:30
} else {
BrowserWindow . getFocusedWindow ( ) . loadURL (
2023-06-11 21:00:20 +05:30
"https://microsoft365.com/launch/word?auth=2"
2023-06-11 20:39:17 +05:30
) ;
}
} else if (
2023-06-11 21:15:36 +05:30
getValue ( "enterprise-or-normal" ) ===
2023-06-11 20:39:17 +05:30
"https://microsoft365.com/?auth=1"
) {
2023-06-11 21:15:36 +05:30
if ( getValue ( "websites-in-new-window" ) === "true" ) {
2023-06-11 20:39:17 +05:30
let wordwindow = new BrowserWindow ( {
width : 800 ,
height : 600 ,
webPreferences : {
nodeIntegration : false ,
contextIsolation : true ,
} ,
} ) ;
2023-06-11 21:00:20 +05:30
wordwindow . loadURL ( "https://microsoft365.com/launch/word?auth=1" ) ;
2023-06-11 20:39:17 +05:30
} else {
BrowserWindow . getFocusedWindow ( ) . loadURL (
2023-06-11 21:00:20 +05:30
"https://microsoft365.com/launch/word?auth=1"
2023-06-11 20:39:17 +05:30
) ;
}
}
} ,
} ,
{
label : "Excel" ,
click : ( ) => {
if (
2023-06-11 21:15:36 +05:30
getValue ( "enterprise-or-normal" ) ===
2023-06-11 20:39:17 +05:30
"https://microsoft365.com/?auth=2"
) {
2023-06-11 21:15:36 +05:30
if ( getValue ( "websites-in-new-window" ) === "true" ) {
2023-06-11 20:39:17 +05:30
let excelwindow = new BrowserWindow ( {
width : 800 ,
height : 600 ,
webPreferences : {
nodeIntegration : false ,
contextIsolation : true ,
} ,
} ) ;
2023-06-11 21:00:20 +05:30
excelwindow . loadURL (
"https://microsoft365.com/launch/excel?auth=2"
) ;
2023-06-11 20:39:17 +05:30
} else {
BrowserWindow . getFocusedWindow ( ) . loadURL (
2023-06-11 21:00:20 +05:30
"https://microsoft365.com/launch/excel?auth=2"
2023-06-11 20:39:17 +05:30
) ;
}
} else if (
2023-06-11 21:15:36 +05:30
getValue ( "enterprise-or-normal" ) ===
2023-06-11 20:39:17 +05:30
"https://microsoft365.com/?auth=1"
) {
2023-06-11 21:15:36 +05:30
if ( getValue ( "websites-in-new-window" ) === "true" ) {
2023-06-11 20:39:17 +05:30
let excelwindow = new BrowserWindow ( {
width : 800 ,
height : 600 ,
webPreferences : {
nodeIntegration : false ,
contextIsolation : true ,
} ,
} ) ;
2023-06-11 21:00:20 +05:30
excelwindow . loadURL (
"https://microsoft365.com/launch/excel?auth=1"
) ;
2023-06-11 20:39:17 +05:30
} else {
BrowserWindow . getFocusedWindow ( ) . loadURL (
2023-06-11 21:00:20 +05:30
"https://microsoft365.com/launch/excel?auth=1"
2023-06-11 20:39:17 +05:30
) ;
}
}
} ,
} ,
{
label : "PowerPoint" ,
click : ( ) => {
if (
2023-06-11 21:15:36 +05:30
getValue ( "enterprise-or-normal" ) ===
2023-06-11 20:39:17 +05:30
"https://microsoft365.com/?auth=2"
) {
2023-06-11 21:15:36 +05:30
if ( getValue ( "websites-in-new-window" ) === "true" ) {
2023-06-11 20:39:17 +05:30
let powerpointwindow = new BrowserWindow ( {
width : 800 ,
height : 600 ,
webPreferences : {
nodeIntegration : false ,
contextIsolation : true ,
} ,
} ) ;
powerpointwindow . loadURL (
2023-06-11 21:00:20 +05:30
"https://microsoft365.com/launch/powerpoint?auth=2"
2023-06-11 20:39:17 +05:30
) ;
} else {
BrowserWindow . getFocusedWindow ( ) . loadURL (
2023-06-11 21:00:20 +05:30
"https://microsoft365.com/launch/powerpoint?auth=2"
2023-06-11 20:39:17 +05:30
) ;
}
} else if (
2023-06-11 21:15:36 +05:30
getValue ( "enterprise-or-normal" ) ===
2023-06-11 20:39:17 +05:30
"https://microsoft365.com/?auth=1"
) {
2023-06-11 21:15:36 +05:30
if ( getValue ( "websites-in-new-window" ) === "true" ) {
2023-06-11 20:39:17 +05:30
let powerpointwindow = new BrowserWindow ( {
width : 800 ,
height : 600 ,
webPreferences : {
nodeIntegration : false ,
contextIsolation : true ,
} ,
} ) ;
powerpointwindow . loadURL (
2023-06-11 21:00:20 +05:30
"https://microsoft365.com/launch/powerpoint?auth=1"
2023-06-11 20:39:17 +05:30
) ;
} else {
BrowserWindow . getFocusedWindow ( ) . loadURL (
2023-06-11 21:00:20 +05:30
"https://microsoft365.com/launch/powerpoint?auth=1"
2023-06-11 20:39:17 +05:30
) ;
}
}
} ,
} ,
{
label : "Outlook" ,
click : ( ) => {
if (
2023-06-11 21:15:36 +05:30
getValue ( "enterprise-or-normal" ) ===
2023-06-11 20:39:17 +05:30
"https://microsoft365.com/?auth=2"
) {
2023-06-11 21:15:36 +05:30
if ( getValue ( "websites-in-new-window" ) === "true" ) {
2023-06-11 20:39:17 +05:30
let outlookwindow = new BrowserWindow ( {
width : 800 ,
height : 600 ,
webPreferences : {
nodeIntegration : false ,
contextIsolation : true ,
} ,
} ) ;
outlookwindow . loadURL ( "https://outlook.office.com/mail/" ) ;
} else {
BrowserWindow . getFocusedWindow ( ) . loadURL (
"https://outlook.office.com/mail/"
) ;
}
} else if (
2023-06-11 21:15:36 +05:30
getValue ( "enterprise-or-normal" ) ===
2023-06-11 20:39:17 +05:30
"https://microsoft365.com/?auth=1"
) {
2023-06-11 21:15:36 +05:30
if ( getValue ( "websites-in-new-window" ) === "true" ) {
2023-06-11 20:39:17 +05:30
let outlookwindow = new BrowserWindow ( {
width : 800 ,
height : 600 ,
webPreferences : {
nodeIntegration : false ,
contextIsolation : true ,
} ,
} ) ;
outlookwindow . loadURL (
"https://office.live.com/start/Outlook.aspx"
) ;
} else {
BrowserWindow . getFocusedWindow ( ) . loadURL (
"https://office.live.com/start/Outlook.aspx"
) ;
}
}
} ,
} ,
2023-06-11 21:00:20 +05:30
{
label : "OneDrive" ,
click : ( ) => {
if (
2023-06-11 21:15:36 +05:30
getValue ( "enterprise-or-normal" ) ===
2023-06-11 21:00:20 +05:30
"https://microsoft365.com/?auth=2"
) {
2023-06-11 21:15:36 +05:30
if ( getValue ( "websites-in-new-window" ) === "true" ) {
2023-06-11 21:00:20 +05:30
let onedrivewindow = new BrowserWindow ( {
width : 800 ,
height : 600 ,
webPreferences : {
nodeIntegration : false ,
contextIsolation : true ,
} ,
} ) ;
onedrivewindow . loadURL (
"https://microsoft365.com/launch/onedrive?auth=2"
) ;
} else {
BrowserWindow . getFocusedWindow ( ) . loadURL (
"https://microsoft365.com/launch/onedrive?auth=2"
) ;
}
} else if (
2023-06-11 21:15:36 +05:30
getValue ( "enterprise-or-normal" ) ===
2023-06-11 21:00:20 +05:30
"https://microsoft365.com/?auth=1"
) {
2023-06-11 21:15:36 +05:30
if ( getValue ( "websites-in-new-window" ) === "true" ) {
2023-06-11 21:00:20 +05:30
let onedrivewindow = new BrowserWindow ( {
width : 800 ,
height : 600 ,
webPreferences : {
nodeIntegration : false ,
contextIsolation : true ,
} ,
} ) ;
2023-06-11 21:15:36 +05:30
onedrivewindow . loadURL (
"https://microsoft365.com/launch/onedrive?auth=1"
) ;
2023-06-11 21:00:20 +05:30
} else {
BrowserWindow . getFocusedWindow ( ) . loadURL (
"https://microsoft365.com/launch/onedrive?auth=1"
) ;
}
}
} ,
} ,
2023-06-11 20:39:17 +05:30
{
label : "OneNote" ,
click : ( ) => {
if (
2023-06-11 21:15:36 +05:30
getValue ( "enterprise-or-normal" ) ===
2023-06-11 20:39:17 +05:30
"https://microsoft365.com/?auth=2"
) {
2023-06-11 21:15:36 +05:30
if ( getValue ( "websites-in-new-window" ) === "true" ) {
2023-06-11 20:39:17 +05:30
let onenotewindow = new BrowserWindow ( {
width : 800 ,
height : 600 ,
webPreferences : {
nodeIntegration : false ,
contextIsolation : true ,
} ,
} ) ;
onenotewindow . loadURL (
"https://www.microsoft365.com/launch/onenote?auth=2"
) ;
} else {
BrowserWindow . getFocusedWindow ( ) . loadURL (
"https://www.microsoft365.com/launch/onenote?auth=2"
) ;
}
} else if (
2023-06-11 21:15:36 +05:30
getValue ( "enterprise-or-normal" ) ===
2023-06-11 20:39:17 +05:30
"https://microsoft365.com/?auth=1"
) {
2023-06-11 21:15:36 +05:30
if ( getValue ( "websites-in-new-window" ) === "true" ) {
2023-06-11 20:39:17 +05:30
let onenotewindow = new BrowserWindow ( {
width : 800 ,
height : 600 ,
webPreferences : {
nodeIntegration : false ,
contextIsolation : true ,
} ,
} ) ;
onenotewindow . loadURL ( "https://www.onenote.com/notebooks?auth=1" ) ;
} else {
BrowserWindow . getFocusedWindow ( ) . loadURL (
"https://www.onenote.com/notebooks?auth=1"
) ;
}
}
} ,
} ,
{
label : "All Apps" ,
click : ( ) => {
if (
2023-06-11 21:15:36 +05:30
getValue ( "enterprise-or-normal" ) ===
2023-06-11 20:39:17 +05:30
"https://microsoft365.com/?auth=2"
) {
2023-06-11 21:15:36 +05:30
if ( getValue ( "websites-in-new-window" ) === "true" ) {
2023-06-11 20:39:17 +05:30
let allappswindow = new BrowserWindow ( {
width : 800 ,
height : 600 ,
webPreferences : {
nodeIntegration : false ,
contextIsolation : true ,
} ,
} ) ;
allappswindow . loadURL ( "https://www.microsoft365.com/apps?auth=2" ) ;
} else {
BrowserWindow . getFocusedWindow ( ) . loadURL (
"https://www.microsoft365.com/apps?auth=2"
) ;
}
} else if (
2023-06-11 21:15:36 +05:30
getValue ( "enterprise-or-normal" ) ===
2023-06-11 20:39:17 +05:30
"https://microsoft365.com/?auth=1"
) {
2023-06-11 21:15:36 +05:30
if ( getValue ( "websites-in-new-window" ) === "true" ) {
2023-06-11 20:39:17 +05:30
let allappswindow = new BrowserWindow ( {
width : 800 ,
height : 600 ,
webPreferences : {
nodeIntegration : false ,
contextIsolation : true ,
} ,
} ) ;
allappswindow . loadURL ( "https://www.microsoft365.com/apps?auth=1" ) ;
} else {
BrowserWindow . getFocusedWindow ( ) . loadURL (
"https://www.microsoft365.com/apps?auth=1"
) ;
}
}
} ,
} ,
] ,
} ,
2023-06-05 20:12:06 +05:30
{
label : "Window" ,
submenu : [
{ role : "minimize" } ,
{ role : "zoom" } ,
... ( process . platform === "darwin"
2023-06-05 20:34:56 +05:30
? [ { type : "separator" } , { role : "front" } , { type : "separator" } ]
: [ { role : "close" } ] ) ,
... ( ! process . platform === "darwin"
2023-06-05 20:12:06 +05:30
? [
{ type : "separator" } ,
2023-06-05 20:34:56 +05:30
{
label : "Show Menu Bar" ,
type : "radio" ,
click : ( ) => {
2023-06-11 21:15:36 +05:30
setValue ( "autohide-menubar" , "false" ) ;
2023-06-05 20:34:56 +05:30
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Menu Bar Settings" ,
message :
"Menu will be visible now. Please restart the app for changes to take effect." ,
buttons : [ "OK" ] ,
} ) ;
} ,
2023-06-11 21:15:36 +05:30
checked : getValue ( "autohide-menubar" ) === "false" ,
2023-06-05 20:34:56 +05:30
} ,
{
label : "Hide Menu Bar (ALT to show)" ,
type : "radio" ,
click : ( ) => {
2023-06-11 21:15:36 +05:30
setValue ( "autohide-menubar" , "true" ) ;
2023-06-05 20:34:56 +05:30
dialog . showMessageBoxSync ( {
type : "info" ,
title : "Menu Bar Settings" ,
message :
"Menu bar will be automatically hidden now. Please restart the app for changes to take effect." ,
buttons : [ "OK" ] ,
} ) ;
} ,
2023-06-11 21:15:36 +05:30
checked : getValue ( "autohide-menubar" ) === "true" ,
2023-06-05 20:34:56 +05:30
} ,
2023-06-05 20:12:06 +05:30
]
2023-06-05 20:34:56 +05:30
: [ ] ) ,
2023-06-05 20:12:06 +05:30
] ,
} ,
] ;
module . exports = { menulayout } ;