Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plugin): WebPWA #2994

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions src/plugins/webPWA/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2024 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/

import "./styles.css";
ThaUnknown marked this conversation as resolved.
Show resolved Hide resolved

import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import { filters, waitFor } from "@webpack";
import { RelationshipStore } from "@webpack/common";

const manifest = {
name: "Discord",
short_name: "Discord",
start_url: "https://discord.com/channels/@me", // URL when PWA launches
ThaUnknown marked this conversation as resolved.
Show resolved Hide resolved
display: "fullscreen",
display_override: ["window-controls-overlay"],
lang: "en-US",
ThaUnknown marked this conversation as resolved.
Show resolved Hide resolved
background_color: "#2a2a2f",
theme_color: "#2a2a2f",
scope: "https://discord.com", // scope of all possible URL"s
ThaUnknown marked this conversation as resolved.
Show resolved Hide resolved
description: "Imagine a place...",
orientation: "landscape",
icons: [
{
src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAAAXNSR0IArs4c6QAAIABJREFUeF7tXQt4VNW1/teZTF5AJgFFFLgClwpYVErxohaVVnqL1So+IEm1bTQJIqK1Vbngq/GBclHrE4pM0FyrzQSsxdeVtrQ+bq5IoQoVBSxFuKIir2SGkNdkzrrdE6IQksw5M+ecOY+d7+Pz85v9WOtfe/9n77XXXpsg/xyNwJSSuvxcP4bE4BtEUAcBvmNUUgcoKo5h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nOY4U4t56bCcf3mWV1zNhHftb33Hi81kWmt/yriQBWA65/g7jpNCcORI+ZTSzOhqsDCEFw8H8LyAq0N+icTWI+QATbQPzdgI2xoDNGaRuzIzWb5bLeeNwNqslSQBmIWtRu+LokTg2KAbfIKgYQAoPAGEAq8j/Z0jsMcTIB1EegGwG9yZCBtAFaYgMuIT2xy2Z6hloIOZGJtQTUA8Fe8HYBfBehrLTh9jOxii2r/BoIg2LzGt6N/8PoMvr9NjXOyAAAAAASUVORK5CYII=",
sizes: "256x256",
type: "image/png"
}
]
};

const isMac = navigator.platform.startsWith("Mac");
ThaUnknown marked this conversation as resolved.
Show resolved Hide resolved

let link: HTMLLinkElement | undefined;

let GuildReadStateStore: any;
let NotificationSettingsStore: any;

function setBadge() {
if (!enabled) return;
try {
const mentionCount = GuildReadStateStore.getTotalMentionCount();
const pendingRequests = RelationshipStore.getPendingCount();
const hasUnread = GuildReadStateStore.hasAnyUnread();
const disableUnreadBadge = NotificationSettingsStore.getDisableUnreadBadge();

let totalCount = mentionCount + pendingRequests;
if (!totalCount && hasUnread && !disableUnreadBadge) totalCount = -1;

navigator.setAppBadge(totalCount);
} catch (e) {
console.error(e);
}
}

let toFind = 3;

function waitForAndSubscribeToStore(name: string, cb?: (m: any) => void) {
waitFor(filters.byStoreName(name), store => {
cb?.(store);
store.addChangeListener(setBadge);

toFind--;
if (toFind === 0) setBadge();
});
}

let enabled = false;

waitForAndSubscribeToStore("GuildReadStateStore", store => (GuildReadStateStore = store));
waitForAndSubscribeToStore("NotificationSettingsStore", store => (NotificationSettingsStore = store));
waitForAndSubscribeToStore("RelationshipStore");
export default definePlugin({
name: "WebPWA",
description: "Allows Discord to be installable and usable as a PWA.",
authors: [Devs.ThaUnknown],
manifest: null,
start() {
const url = URL.createObjectURL(new Blob([JSON.stringify(manifest)], { type: "application/json" }));
enabled = true;
link = document.createElement("link");
link.rel = "manifest";
link.href = url;
},
stop() {
link?.remove();
enabled = false;
navigator.setAppBadge(0);
},
patches: [
{
find: "platform-web",
replacement: {
// eslint-disable-next-line no-useless-escape
match: /(?<=" platform-overlay"\):)\i/,
replace: "$self.getPlatformClass()"
}
},
ThaUnknown marked this conversation as resolved.
Show resolved Hide resolved
{
find: "\"NotificationSettingsStore",
replacement: {
// eslint-disable-next-line no-useless-escape
match: /\.isPlatformEmbedded(?=\?\i\.\i\.ALL)/g,
replace: "$&||true"
}
}
],

getPlatformClass() {
if (isMac) return "platform-osx";
return "platform-win";
}
});
11 changes: 11 additions & 0 deletions src/plugins/webPWA/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* Download Desktop button in guilds list */
[class^="listItem_"]:has([data-list-item-id="guildsnav___app-download-button"]),
[class^="listItem_"]:has(+ [class^="listItem_"] [data-list-item-id="guildsnav___app-download-button"]) {
display: none;
}

/* Workaround for making things in the draggable area clickable again on macOS */
.platform-osx [class*="topic_"],
.platform-osx [class*="notice_"] button {
-webkit-app-region: no-drag;
}
6 changes: 5 additions & 1 deletion src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,14 @@ export const Devs = /* #__PURE__*/ Object.freeze({
name: "RamziAH",
id: 1279957227612147747n,
},
SomeAspy: {
SomeAspy: {
name: "SomeAspy",
id: 516750892372852754n,
},
ThaUnknown: {
name: "ThaUnknown_",
id: 252390917665718273n
},
} satisfies Record<string, Dev>);

// iife so #__PURE__ works correctly
Expand Down