mirror of
https://github.com/agam778/MS-365-Electron.git
synced 2026-02-17 09:02:10 +00:00
Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f82837ac4f | ||
|
|
6c1edd0a98 | ||
|
|
72516bd2fd | ||
|
|
38a4db3538 | ||
|
|
aab2397043 | ||
|
|
034e2f36c3 | ||
|
|
b44ee69787 | ||
|
|
0ba2721ea3 | ||
|
|
d2ed102ccc | ||
|
|
dd8110479b | ||
|
|
848e93ae09 | ||
|
|
1625a46529 | ||
|
|
1526a81d1c | ||
|
|
5b4db16b64 | ||
|
|
0e02c64999 | ||
|
|
9d2b63fedb | ||
|
|
15d339d7f9 | ||
|
|
ec12b02d7e | ||
|
|
e003c64444 | ||
|
|
e680f8eb37 | ||
|
|
1e1828b3f2 | ||
|
|
a9d63d7325 | ||
|
|
95e14db4f8 | ||
|
|
6a294dadd0 |
BIN
.yarn/cache/about-window-npm-1.15.2-6500c751aa-0e528f6312.zip
vendored
Normal file
BIN
.yarn/cache/about-window-npm-1.15.2-6500c751aa-0e528f6312.zip
vendored
Normal file
Binary file not shown.
1
LICENSE
1
LICENSE
@@ -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
|
||||
|
||||
18
README.md
18
README.md
@@ -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
|
||||
|
||||
422
app/main.js
422
app/main.js
@@ -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...`);
|
||||
}
|
||||
|
||||
1269
app/menu.js
1269
app/menu.js
File diff suppressed because it is too large
Load Diff
36
app/rpc.js
36
app/rpc.js
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
19
app/store.js
19
app/store.js
@@ -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 };
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user