mirror of
https://github.com/agam778/MS-365-Electron.git
synced 2026-02-17 09:02:10 +00:00
Welcome back, Discord RPC
- Use new image for the RPC - Switch to an updated library
This commit is contained in:
BIN
.yarn/cache/@xhayper-discord-rpc-npm-1.0.17-a35e6bd739-6b7f4d2590.zip
vendored
Normal file
BIN
.yarn/cache/@xhayper-discord-rpc-npm-1.0.17-a35e6bd739-6b7f4d2590.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/axios-npm-1.4.0-4d7ce8ca3e-7fb6a4313b.zip
vendored
Normal file
BIN
.yarn/cache/axios-npm-1.4.0-4d7ce8ca3e-7fb6a4313b.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/discord-api-types-npm-0.37.43-26a217da1d-716bafb6b2.zip
vendored
Normal file
BIN
.yarn/cache/discord-api-types-npm-0.37.43-26a217da1d-716bafb6b2.zip
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/ws-npm-8.13.0-26ffa3016a-53e991bbf9.zip
vendored
Normal file
BIN
.yarn/cache/ws-npm-8.13.0-26ffa3016a-53e991bbf9.zip
vendored
Normal file
Binary file not shown.
22
app/main.js
22
app/main.js
@@ -6,7 +6,7 @@ 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");
|
||||
|
||||
log.transports.file.level = "verbose";
|
||||
@@ -116,9 +116,14 @@ function createWindow() {
|
||||
}
|
||||
);
|
||||
|
||||
require("./rpc.js");
|
||||
|
||||
win.webContents.on("did-finish-load", () => {
|
||||
splash.destroy();
|
||||
win.show();
|
||||
if (store.get("discordrpcstatus") === "true") {
|
||||
setActivity(`On "${win.webContents.getTitle()}"`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -133,9 +138,19 @@ app.on("web-contents-created", (event, contents) => {
|
||||
return { action: "allow" };
|
||||
} else {
|
||||
BrowserWindow.getFocusedWindow().loadURL(url);
|
||||
if (store.get("discordrpcstatus") === "true") {
|
||||
setActivity(
|
||||
`On "${BrowserWindow.getFocusedWindow().webContents.getTitle()}"`
|
||||
);
|
||||
}
|
||||
return { action: "deny" };
|
||||
}
|
||||
} else {
|
||||
if (store.get("discordrpcstatus") === "true") {
|
||||
setActivity(
|
||||
`On "${BrowserWindow.getFocusedWindow().webContents.getTitle()}"`
|
||||
);
|
||||
}
|
||||
return { action: "allow" };
|
||||
}
|
||||
});
|
||||
@@ -145,6 +160,7 @@ app.on("window-all-closed", () => {
|
||||
if (process.platform !== "darwin") {
|
||||
app.quit();
|
||||
}
|
||||
clearActivity();
|
||||
});
|
||||
|
||||
app.on("activate", () => {
|
||||
@@ -173,4 +189,8 @@ app.on("ready", function () {
|
||||
});
|
||||
});
|
||||
autoUpdater.checkForUpdatesAndNotify();
|
||||
if (store.get("discordrpcstatus") === "true") {
|
||||
loginToRPC();
|
||||
setActivity(`Opening Microsoft 365...`);
|
||||
}
|
||||
});
|
||||
|
||||
36
app/menu.js
36
app/menu.js
@@ -2,6 +2,7 @@ const store = require("./store");
|
||||
const useragents = require("./useragents.json");
|
||||
const { app, dialog, BrowserWindow } = require("electron");
|
||||
const axios = require("axios");
|
||||
const { clearActivity, setActivity } = require("./rpc");
|
||||
|
||||
function getValueOrDefault(key, defaultValue) {
|
||||
const value = store.get(key);
|
||||
@@ -87,6 +88,7 @@ function setUserAgent(useragent) {
|
||||
getValueOrDefault("enterprise-or-normal", "https://microsoft365.com/?auth=1");
|
||||
getValueOrDefault("autohide-menubar", "false");
|
||||
getValueOrDefault("useragentstring", useragents.Windows);
|
||||
getValueOrDefault("discordrpcstatus", "false");
|
||||
|
||||
const menulayout = [
|
||||
{
|
||||
@@ -187,6 +189,40 @@ const menulayout = [
|
||||
: false,
|
||||
},
|
||||
{ type: "separator" },
|
||||
{
|
||||
label: "Enable Discord RPC",
|
||||
type: "checkbox",
|
||||
click: () => {
|
||||
if (store.get("discordrpcstatus") === "true") {
|
||||
store.set("discordrpcstatus", "false");
|
||||
dialog.showMessageBoxSync({
|
||||
type: "info",
|
||||
title: "Discord RPC",
|
||||
message: "Discord RPC has been disabled.",
|
||||
buttons: ["OK"],
|
||||
});
|
||||
clearActivity();
|
||||
return;
|
||||
} else if (
|
||||
store.get("discordrpcstatus") === "false" ||
|
||||
store.get("discordrpcstatus") === undefined
|
||||
) {
|
||||
store.set("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: store.get("discordrpcstatus") === "true",
|
||||
},
|
||||
{ type: "separator" },
|
||||
{
|
||||
label: "Windows User-Agent String",
|
||||
type: "radio",
|
||||
|
||||
57
app/rpc.js
Normal file
57
app/rpc.js
Normal file
@@ -0,0 +1,57 @@
|
||||
const { Client } = require("@xhayper/discord-rpc");
|
||||
const { dialog, BrowserWindow } = require("electron");
|
||||
|
||||
const client = new Client({
|
||||
clientId: "942637872530460742",
|
||||
});
|
||||
|
||||
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"],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function setActivity(details) {
|
||||
if (!client.user) {
|
||||
await loginToRPC();
|
||||
}
|
||||
await client.user
|
||||
?.setActivity({
|
||||
details: details,
|
||||
startTimestamp: Date.now(),
|
||||
largeImageKey: "icon",
|
||||
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"],
|
||||
});
|
||||
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"],
|
||||
});
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
clearActivity,
|
||||
setActivity,
|
||||
loginToRPC,
|
||||
};
|
||||
@@ -72,6 +72,7 @@
|
||||
"eslint": "^8.36.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@xhayper/discord-rpc": "^1.0.17",
|
||||
"axios": "^1.3.4",
|
||||
"check-internet-connected": "^2.0.6",
|
||||
"electron-context-menu": "^3.6.1",
|
||||
|
||||
45
yarn.lock
45
yarn.lock
@@ -363,6 +363,17 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@xhayper/discord-rpc@npm:^1.0.17":
|
||||
version: 1.0.17
|
||||
resolution: "@xhayper/discord-rpc@npm:1.0.17"
|
||||
dependencies:
|
||||
axios: ^1.4.0
|
||||
discord-api-types: ^0.37.42
|
||||
ws: ^8.13.0
|
||||
checksum: 6b7f4d25900dae4cdffc739e71042e5a980df680d767b10e29738372f8312b793cf654d339355ae382677efb7f263b09e150ec1fe84a2691bb70dff4c6afafd8
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"abbrev@npm:^1.0.0":
|
||||
version: 1.1.1
|
||||
resolution: "abbrev@npm:1.1.1"
|
||||
@@ -624,6 +635,17 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"axios@npm:^1.4.0":
|
||||
version: 1.4.0
|
||||
resolution: "axios@npm:1.4.0"
|
||||
dependencies:
|
||||
follow-redirects: ^1.15.0
|
||||
form-data: ^4.0.0
|
||||
proxy-from-env: ^1.1.0
|
||||
checksum: 7fb6a4313bae7f45e89d62c70a800913c303df653f19eafec88e56cea2e3821066b8409bc68be1930ecca80e861c52aa787659df0ffec6ad4d451c7816b9386b
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"balanced-match@npm:^1.0.0":
|
||||
version: 1.0.2
|
||||
resolution: "balanced-match@npm:1.0.2"
|
||||
@@ -1130,6 +1152,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"discord-api-types@npm:^0.37.42":
|
||||
version: 0.37.43
|
||||
resolution: "discord-api-types@npm:0.37.43"
|
||||
checksum: 716bafb6b2881fd0bb36edae67ec04d08e393ff80b762c74376a40d99cf6dace71d9b13242cea95df1fb9db3aa64fd3e94719dc983420e3b3e139f0e77258489
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"dmg-builder@npm:23.6.0":
|
||||
version: 23.6.0
|
||||
resolution: "dmg-builder@npm:23.6.0"
|
||||
@@ -2573,6 +2602,7 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "ms-365-electron@workspace:."
|
||||
dependencies:
|
||||
"@xhayper/discord-rpc": ^1.0.17
|
||||
axios: ^1.3.4
|
||||
check-internet-connected: ^2.0.6
|
||||
electron: ^23.2.0
|
||||
@@ -3565,6 +3595,21 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ws@npm:^8.13.0":
|
||||
version: 8.13.0
|
||||
resolution: "ws@npm:8.13.0"
|
||||
peerDependencies:
|
||||
bufferutil: ^4.0.1
|
||||
utf-8-validate: ">=5.0.2"
|
||||
peerDependenciesMeta:
|
||||
bufferutil:
|
||||
optional: true
|
||||
utf-8-validate:
|
||||
optional: true
|
||||
checksum: 53e991bbf928faf5dc6efac9b8eb9ab6497c69feeb94f963d648b7a3530a720b19ec2e0ec037344257e05a4f35bd9ad04d9de6f289615ffb133282031b18c61c
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"xmlbuilder@npm:>=11.0.1":
|
||||
version: 15.1.1
|
||||
resolution: "xmlbuilder@npm:15.1.1"
|
||||
|
||||
Reference in New Issue
Block a user