Compare commits

...

24 Commits

Author SHA1 Message Date
Agampreet Singh
f82837ac4f Update README.md 2023-06-12 23:54:50 +05:30
Agampreet Singh
6c1edd0a98 Do not include assets/icons in extraFiles 2023-06-12 19:41:25 +05:30
Agampreet Singh
72516bd2fd Add a "Copy URL" button in menu 2023-06-12 15:15:33 +05:30
Agampreet Singh
38a4db3538 Rearrange menu 2023-06-12 15:01:02 +05:30
Agampreet Singh
aab2397043 Use a better way to check menu item 2023-06-12 13:27:49 +05:30
Agampreet Singh
034e2f36c3 Shorten menu label/description 2023-06-12 13:27:41 +05:30
Agampreet Singh
b44ee69787 Make the menu feel more native 2023-06-12 12:42:59 +05:30
Agampreet Singh
0ba2721ea3 Add option to enable/disable auto updater 2023-06-12 00:49:47 +05:30
Agampreet Singh
d2ed102ccc Rearrange MS-365-Electron menu 2023-06-12 00:35:08 +05:30
Agampreet Singh
dd8110479b Add accelerator for Back, Forward and Reload buttons 2023-06-11 23:24:54 +05:30
Agampreet Singh
848e93ae09 Let user enable/disable "Dynamic Icons"
- Auto Icon Changer will be called "Dynamic Icons" from now on
2023-06-11 23:20:17 +05:30
Agampreet Singh
1625a46529 Only keep "Block Ads and Trackers" option 2023-06-11 22:50:00 +05:30
Agampreet Singh
1526a81d1c Update user-agent strings 2023-06-11 21:54:56 +05:30
Agampreet Singh
5b4db16b64 Do not log if internet is connected 2023-06-11 21:49:09 +05:30
Agampreet Singh
0e02c64999 Cleanup the main file 2023-06-11 21:48:03 +05:30
Agampreet Singh
9d2b63fedb Move everything related to store in store.js 2023-06-11 21:15:36 +05:30
Agampreet Singh
15d339d7f9 Add OneDrive option under Apps menu 2023-06-11 21:00:59 +05:30
Agampreet Singh
ec12b02d7e Add "Apps" menu 2023-06-11 21:00:49 +05:30
Agampreet Singh
e003c64444 Update LICENSE 2023-06-11 18:17:38 +05:30
Agampreet Singh
e680f8eb37 Welcome back about-window! 2023-06-11 18:16:30 +05:30
Agampreet Singh
1e1828b3f2 Rename menu label 2023-06-11 17:49:27 +05:30
Agampreet Singh
a9d63d7325 Use rpcError function for all RPC related errors
- Also add "Disable Discord RPC" button to the error message
2023-06-11 17:48:30 +05:30
Agampreet Singh
95e14db4f8 Only change icons if some window is focused
- This commit fixes the error shown if no window is focused
2023-06-11 17:39:53 +05:30
Agampreet Singh
6a294dadd0 Use URL to check which website is opened 2023-06-11 17:39:02 +05:30
10 changed files with 1240 additions and 541 deletions

Binary file not shown.

View File

@@ -1,6 +1,7 @@
MIT License
Copyright (c) 2021-2023 Agampreet Singh
Microsoft 365, the name, website, images/icons are the intellectual properties of Microsoft.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -72,6 +72,13 @@ Supported Platforms
# List of Features
- Discord RPC
- Dynamic Icons:
- For macOS: Change icon in dock according to the app you've opened [[Preview]](https://github-production-user-asset-6210df.s3.amazonaws.com/68941022/245203309-3d0dfc1b-02e9-43a8-85d7-9493a2b86b56.mp4)
- For Windows: Set overlay icon [[Preview]](https://github.com/agam778/MS-365-Electron/assets/68941022/791b661b-2b7d-43a6-96df-ee9c30c9b18a)
- For Linux: Nothing, yet
- Block Ads within the app
- Directly open apps from the menu
- Ability to use useragent strings of Windows, macOS or Linux
- Switch between normal and enterprise/education/developer account in the same app
- Back, Forward, Reload, and Home buttons
@@ -105,6 +112,13 @@ For Installing this app on Mac :-
2. Scroll down and click the `.dmg` file (according to your system architecture).
3. After it downloads, click on the file and mount it on your system. Now drag my app to the Applications Folder (There will be a shortcut in the opened window too) and your app will be installed. Open from Launchpad and enjoy.
## 📸 macOS Preview
<details>
<summary>Click to expand</summary>
<img src="https://github.com/agam778/MS-365-Electron/assets/68941022/fcc24409-7e4b-4802-9f3f-a7c420c0edcb" alt="macOS Preview">
</details>
# Linux
## 💿 Installation on Linux
@@ -159,10 +173,6 @@ For Installing in Red Hat/Fedora based distribution :-
sudo emerge -a ms-office-electron
```
## 📸 Ubuntu Preview
[Click Here](https://github.com/agam778/MS-365-Electron/blob/main/assets/screenshots/ubuntu.png?raw=true)
# 💻 Developing Locally
To build the app locally:<br>
Run the following commands to clone the repository and install the dependencies

View File

@@ -4,16 +4,66 @@ const checkInternetConnected = require("check-internet-connected");
const ElectronDl = require("electron-dl");
const contextMenu = require("electron-context-menu");
const path = require("path");
const store = require("./store");
const log = require("electron-log");
const { setActivity, loginToRPC, clearActivity } = require("./rpc");
const useragents = require("./useragents.json");
const { ElectronBlocker } = require("@cliqz/adblocker-electron");
const { getValue } = require("./store");
const { menulayout } = require("./menu");
log.transports.file.level = "verbose";
console.log = log.log;
Object.assign(console, log.functions);
function createWindow() {
const win = new BrowserWindow({
width: 1181,
height: 670,
icon: path.join(__dirname, "/assets/icons/png/1024x1024.png"),
show: false,
webPreferences: {
nodeIntegration: true,
devTools: true,
},
});
if (getValue("autohide-menubar") === "true") {
win.setAutoHideMenuBar(true);
} else {
win.setAutoHideMenuBar(false);
}
const splash = new BrowserWindow({
width: 810,
height: 610,
transparent: true,
frame: false,
alwaysOnTop: true,
icon: path.join(__dirname, "/assets/icons/png/1024x1024.png"),
});
splash.loadURL(`https://agam778.github.io/MS-365-Electron/loading`);
win.loadURL(
`${getValue("enterprise-or-normal") || "https://microsoft365.com/?auth=1"}`,
{
userAgent: getValue("useragentstring") || useragents.Windows,
}
);
win.webContents.on("did-finish-load", () => {
splash.destroy();
win.show();
if (getValue("discordrpcstatus") === "true") {
setActivity(`On "${win.webContents.getTitle()}"`);
}
if (getValue("blockadsandtrackers") === "true") {
ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => {
blocker.enableBlockingInSession(win.webContents.session);
});
}
});
}
ElectronDl({
dlPath: "./downloads",
onStarted: (item) => {
@@ -75,68 +125,7 @@ contextMenu({
showServices: false,
});
const { menulayout } = require("./menu");
const menu = Menu.buildFromTemplate(menulayout);
Menu.setApplicationMenu(menu);
function createWindow() {
const win = new BrowserWindow({
width: 1181,
height: 670,
icon: path.join(__dirname, "/assets/icons/png/1024x1024.png"),
show: false,
webPreferences: {
nodeIntegration: true,
devTools: true,
},
});
if (store.get("autohide-menubar") === "true") {
win.setAutoHideMenuBar(true);
} else {
win.setAutoHideMenuBar(false);
}
const splash = new BrowserWindow({
width: 810,
height: 610,
transparent: true,
frame: false,
alwaysOnTop: true,
icon: path.join(__dirname, "/assets/icons/png/1024x1024.png"),
});
splash.loadURL(`https://agam778.github.io/MS-365-Electron/loading`);
win.loadURL(
`${
store.get("enterprise-or-normal") || "https://microsoft365.com/?auth=1"
}`,
{
userAgent: store.get("useragentstring") || useragents.Windows,
}
);
require("./rpc.js");
win.webContents.on("did-finish-load", () => {
splash.destroy();
win.show();
if (store.get("discordrpcstatus") === "true") {
setActivity(`On "${win.webContents.getTitle()}"`);
}
if (store.get("blockads") === "true") {
ElectronBlocker.fromPrebuiltAdsOnly(fetch).then((blocker) => {
blocker.enableBlockingInSession(win.webContents.session);
});
}
if (store.get("blockadsandtrackers") === "true") {
ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => {
blocker.enableBlockingInSession(win.webContents.session);
});
}
});
}
Menu.setApplicationMenu(Menu.buildFromTemplate(menulayout));
app.on("ready", () => {
createWindow();
@@ -144,12 +133,12 @@ app.on("ready", () => {
app.on("web-contents-created", (event, contents) => {
contents.setWindowOpenHandler(({ url }) => {
if (store.get("websites-in-new-window") === "false") {
if (getValue("websites-in-new-window") === "false") {
if (url.includes("page=Download")) {
return { action: "allow" };
} else {
BrowserWindow.getFocusedWindow().loadURL(url);
if (store.get("discordrpcstatus") === "true") {
if (getValue("discordrpcstatus") === "true") {
setActivity(
`On "${BrowserWindow.getFocusedWindow().webContents.getTitle()}"`
);
@@ -157,7 +146,7 @@ app.on("web-contents-created", (event, contents) => {
return { action: "deny" };
}
} else {
if (store.get("discordrpcstatus") === "true") {
if (getValue("discordrpcstatus") === "true") {
setActivity(
`On "${BrowserWindow.getFocusedWindow().webContents.getTitle()}"`
);
@@ -166,132 +155,136 @@ app.on("web-contents-created", (event, contents) => {
}
});
contents.on("did-finish-load", () => {
if (
BrowserWindow.getFocusedWindow()
.webContents.getTitle()
.includes("Microsoft PowerPoint")
) {
if (process.platform === "darwin") {
app.dock.setIcon(
path.join(__dirname, "../assets/icons/apps/powerpoint-mac.png")
);
} else if (process.platform === "win32") {
let nimage = nativeImage.createFromPath(
path.join(__dirname, "../assets/icons/apps/powerpoint.png")
);
BrowserWindow.getAllWindows().forEach((window) => {
window.setOverlayIcon(nimage, "PowerPoint");
});
}
} else if (
BrowserWindow.getFocusedWindow()
.webContents.getTitle()
.includes("Microsoft Word")
) {
if (process.platform === "darwin") {
app.dock.setIcon(
path.join(__dirname, "../assets/icons/apps/word-mac.png")
);
} else if (process.platform === "win32") {
let nimage = nativeImage.createFromPath(
path.join(__dirname, "../assets/icons/apps/word.png")
);
BrowserWindow.getAllWindows().forEach((window) => {
window.setOverlayIcon(nimage, "Word");
});
}
} else if (
BrowserWindow.getFocusedWindow()
.webContents.getTitle()
.includes("Microsoft Excel")
) {
if (process.platform === "darwin") {
app.dock.setIcon(
path.join(__dirname, "../assets/icons/apps/excel-mac.png")
);
} else if (process.platform === "win32") {
let nimage = nativeImage.createFromPath(
path.join(__dirname, "../assets/icons/apps/excel.png")
);
BrowserWindow.getAllWindows().forEach((window) => {
window.setOverlayIcon(nimage, "Excel");
});
}
} else if (
BrowserWindow.getFocusedWindow()
.webContents.getTitle()
.includes("Outlook")
) {
if (process.platform === "darwin") {
app.dock.setIcon(
path.join(__dirname, "../assets/icons/apps/outlook-mac.png")
);
} else if (process.platform === "win32") {
let nimage = nativeImage.createFromPath(
path.join(__dirname, "../assets/icons/apps/outlook.png")
);
BrowserWindow.getAllWindows().forEach((window) => {
window.setOverlayIcon(nimage, "Outlook");
});
}
} else if (
BrowserWindow.getFocusedWindow()
.webContents.getTitle()
.includes("OneDrive")
) {
if (process.platform === "darwin") {
app.dock.setIcon(
path.join(__dirname, "../assets/icons/apps/onedrive-mac.png")
);
} else if (process.platform === "win32") {
let nimage = nativeImage.createFromPath(
path.join(__dirname, "../assets/icons/apps/onedrive.png")
);
BrowserWindow.getAllWindows().forEach((window) => {
window.setOverlayIcon(nimage, "OneDrive");
});
}
} else if (
BrowserWindow.getFocusedWindow()
.webContents.getTitle()
.includes("Microsoft Teams")
) {
if (process.platform === "darwin") {
app.dock.setIcon(
path.join(__dirname, "../assets/icons/apps/teams-mac.png")
);
} else if (process.platform === "win32") {
let nimage = nativeImage.createFromPath(
path.join(__dirname, "../assets/icons/apps/teams.png")
);
BrowserWindow.getAllWindows().forEach((window) => {
window.setOverlayIcon(nimage, "Teams");
});
}
} else if (
BrowserWindow.getFocusedWindow()
.webContents.getTitle()
.includes("Microsoft OneNote Online")
) {
if (process.platform === "darwin") {
app.dock.setIcon(
path.join(__dirname, "../assets/icons/apps/onenote-mac.png")
);
} else if (process.platform === "win32") {
let nimage = nativeImage.createFromPath(
path.join(__dirname, "../assets/icons/apps/onenote.png")
);
BrowserWindow.getAllWindows().forEach((window) => {
window.setOverlayIcon(nimage, "OneNote");
});
}
} else {
if (process.platform === "darwin") {
app.dock.setIcon(null);
} else {
BrowserWindow.getAllWindows().forEach((window) => {
window.setOverlayIcon(null, "");
});
if (getValue("dynamicicons") === "true") {
if (BrowserWindow.getFocusedWindow()) {
if (
BrowserWindow.getFocusedWindow()
.webContents.getURL()
.includes("&ithint=file%2cpptx")
) {
if (process.platform === "darwin") {
app.dock.setIcon(
path.join(__dirname, "../assets/icons/apps/powerpoint-mac.png")
);
} else if (process.platform === "win32") {
let nimage = nativeImage.createFromPath(
path.join(__dirname, "../assets/icons/apps/powerpoint.png")
);
BrowserWindow.getAllWindows().forEach((window) => {
window.setOverlayIcon(nimage, "PowerPoint");
});
}
} else if (
BrowserWindow.getFocusedWindow()
.webContents.getURL()
.includes("&ithint=file%2cdocx")
) {
if (process.platform === "darwin") {
app.dock.setIcon(
path.join(__dirname, "../assets/icons/apps/word-mac.png")
);
} else if (process.platform === "win32") {
let nimage = nativeImage.createFromPath(
path.join(__dirname, "../assets/icons/apps/word.png")
);
BrowserWindow.getAllWindows().forEach((window) => {
window.setOverlayIcon(nimage, "Word");
});
}
} else if (
BrowserWindow.getFocusedWindow()
.webContents.getURL()
.includes("&ithint=file%2cxlsx")
) {
if (process.platform === "darwin") {
app.dock.setIcon(
path.join(__dirname, "../assets/icons/apps/excel-mac.png")
);
} else if (process.platform === "win32") {
let nimage = nativeImage.createFromPath(
path.join(__dirname, "../assets/icons/apps/excel.png")
);
BrowserWindow.getAllWindows().forEach((window) => {
window.setOverlayIcon(nimage, "Excel");
});
}
} else if (
BrowserWindow.getFocusedWindow()
.webContents.getURL()
.includes("outlook.live.com")
) {
if (process.platform === "darwin") {
app.dock.setIcon(
path.join(__dirname, "../assets/icons/apps/outlook-mac.png")
);
} else if (process.platform === "win32") {
let nimage = nativeImage.createFromPath(
path.join(__dirname, "../assets/icons/apps/outlook.png")
);
BrowserWindow.getAllWindows().forEach((window) => {
window.setOverlayIcon(nimage, "Outlook");
});
}
} else if (
BrowserWindow.getFocusedWindow()
.webContents.getURL()
.includes("onedrive.live.com")
) {
if (process.platform === "darwin") {
app.dock.setIcon(
path.join(__dirname, "../assets/icons/apps/onedrive-mac.png")
);
} else if (process.platform === "win32") {
let nimage = nativeImage.createFromPath(
path.join(__dirname, "../assets/icons/apps/onedrive.png")
);
BrowserWindow.getAllWindows().forEach((window) => {
window.setOverlayIcon(nimage, "OneDrive");
});
}
} else if (
BrowserWindow.getFocusedWindow()
.webContents.getURL()
.includes("teams.live.com")
) {
if (process.platform === "darwin") {
app.dock.setIcon(
path.join(__dirname, "../assets/icons/apps/teams-mac.png")
);
} else if (process.platform === "win32") {
let nimage = nativeImage.createFromPath(
path.join(__dirname, "../assets/icons/apps/teams.png")
);
BrowserWindow.getAllWindows().forEach((window) => {
window.setOverlayIcon(nimage, "Teams");
});
}
} else if (
BrowserWindow.getFocusedWindow()
.webContents.getURL()
.includes("&ithint=onenote")
) {
if (process.platform === "darwin") {
app.dock.setIcon(
path.join(__dirname, "../assets/icons/apps/onenote-mac.png")
);
} else if (process.platform === "win32") {
let nimage = nativeImage.createFromPath(
path.join(__dirname, "../assets/icons/apps/onenote.png")
);
BrowserWindow.getAllWindows().forEach((window) => {
window.setOverlayIcon(nimage, "OneNote");
});
}
} else {
if (process.platform === "darwin") {
app.dock.setIcon(null);
} else {
BrowserWindow.getAllWindows().forEach((window) => {
window.setOverlayIcon(null, "");
});
}
}
}
}
});
@@ -299,16 +292,11 @@ app.on("web-contents-created", (event, contents) => {
app.on("browser-window-created", (event, window) => {
window.webContents.on("did-finish-load", () => {
if (store.get("discordrpcstatus") === "true") {
if (getValue("discordrpcstatus") === "true") {
setActivity(`On "${window.webContents.getTitle()}"`);
}
});
if (store.get("blockads") === "true") {
ElectronBlocker.fromPrebuiltAdsOnly(fetch).then((blocker) => {
blocker.enableBlockingInSession(window.webContents.session);
});
}
if (store.get("blockadsandtrackers") === "true") {
if (getValue("blockadsandtrackers") === "true") {
ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => {
blocker.enableBlockingInSession(window.webContents.session);
});
@@ -332,26 +320,24 @@ app.on("activate", () => {
});
app.on("ready", function () {
checkInternetConnected()
.then(() => {
console.log("You are connected to the internet!");
})
.catch(() => {
const options = {
type: "warning",
buttons: ["Ok"],
defaultId: 2,
title: "Warning",
message: "You appear to be offline!",
detail:
"Please check your Internet Connectivity. This app cannot run without an Internet Connection!",
};
dialog.showMessageBox(null, options, (response) => {
console.log(response);
});
checkInternetConnected().catch(() => {
const options = {
type: "warning",
buttons: ["Ok"],
defaultId: 2,
title: "Warning",
message: "You appear to be offline!",
detail:
"Please check your Internet Connectivity. This app cannot run without an Internet Connection!",
};
dialog.showMessageBox(null, options, (response) => {
console.log(response);
});
autoUpdater.checkForUpdatesAndNotify();
if (store.get("discordrpcstatus") === "true") {
});
if (getValue("autoupdater") === "true") {
autoUpdater.checkForUpdatesAndNotify();
}
if (getValue("discordrpcstatus") === "true") {
loginToRPC();
setActivity(`Opening Microsoft 365...`);
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +1,28 @@
const { Client } = require("@xhayper/discord-rpc");
const { dialog, BrowserWindow } = require("electron");
const { setValue } = require("./store");
const client = new Client({
clientId: "942637872530460742",
});
async function rpcError(status) {
const rpcerror = dialog.showMessageBoxSync(BrowserWindow.getFocusedWindow(), {
type: "error",
title: "Discord RPC Error",
message: `Oops! An Error occured while ${status} Discord RPC.`,
buttons: ["Close", "Disable Discord RPC"],
});
if (rpcerror === 1) {
setValue("discordrpcstatus", "false");
}
}
async function clearActivity() {
await client.user?.clearActivity().catch((err) => {
dialog.showMessageBox(BrowserWindow.getFocusedWindow(), {
type: "error",
title: "Discord RPC Error",
message: "Oops! An Error occured while clearing Discord RPC.",
buttons: ["OK"],
});
rpcError("clearing");
console.error(err);
});
}
@@ -28,24 +38,14 @@ async function setActivity(details) {
largeImageText: "MS-365-Electron",
})
.catch((err) => {
dialog.showMessageBox(BrowserWindow.getFocusedWindow(), {
type: "error",
title: "Discord RPC Error",
message: "Oops! An Error occured while setting Discord RPC.",
buttons: ["OK"],
});
rpcError("setting");
console.error(err);
});
}
async function loginToRPC() {
await client.login().catch((err) => {
dialog.showMessageBox(BrowserWindow.getFocusedWindow(), {
type: "error",
title: "Discord RPC Error",
message: "Oops! An Error occured while connecting to Discord RPC.",
buttons: ["OK"],
});
rpcError("logging into");
console.error(err);
});
}

View File

@@ -1,4 +1,21 @@
const Store = require("electron-store");
const store = new Store();
module.exports = store;
function getValue(key) {
return store.get(key);
}
function setValue(key, value) {
store.set(key, value);
}
function getValueOrDefault(key, defaultValue) {
const value = store.get(key);
if (value === undefined) {
store.set(key, defaultValue);
return defaultValue;
}
return value;
}
module.exports = { getValue, setValue, getValueOrDefault };

View File

@@ -1,5 +1,5 @@
{
"Windows": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36",
"macOS": "Mozilla/5.0 (Macintosh; Intel Mac OS X 13_2_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36",
"Linux": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
"Windows": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",
"macOS": "Mozilla/5.0 (Macintosh; Intel Mac OS X 13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",
"Linux": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
}

View File

@@ -14,7 +14,6 @@
},
"build": {
"extraFiles": [
"/assets/icons",
"LICENSE"
],
"appId": "com.agampreet.ms-365-electron",
@@ -74,6 +73,7 @@
"dependencies": {
"@cliqz/adblocker-electron": "^1.26.6",
"@xhayper/discord-rpc": "^1.0.17",
"about-window": "^1.15.2",
"axios": "^1.4.0",
"check-internet-connected": "^2.0.6",
"cross-fetch": "^3.1.6",

View File

@@ -524,6 +524,13 @@ __metadata:
languageName: node
linkType: hard
"about-window@npm:^1.15.2":
version: 1.15.2
resolution: "about-window@npm:1.15.2"
checksum: 0e528f6312d2dc3801926f056230e5c6c253f4be16449b4c01b115a2dd24e8b6897f8ba8c07880097415936b9c40a04c10954558af3a6d05d76a11d8a07875d8
languageName: node
linkType: hard
"acorn-jsx@npm:^5.3.2":
version: 5.3.2
resolution: "acorn-jsx@npm:5.3.2"
@@ -2744,6 +2751,7 @@ __metadata:
dependencies:
"@cliqz/adblocker-electron": ^1.26.6
"@xhayper/discord-rpc": ^1.0.17
about-window: ^1.15.2
axios: ^1.4.0
check-internet-connected: ^2.0.6
cross-fetch: ^3.1.6