Merge remote-tracking branch 'upstream/dev' into dev
This commit is contained in:
commit
3b4b2cc75e
2 changed files with 61 additions and 1 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "equicord",
|
"name": "equicord",
|
||||||
"private": "true",
|
"private": "true",
|
||||||
"version": "1.15.8.0",
|
"version": "1.15.9.0",
|
||||||
"description": "The other cutest Discord client mod",
|
"description": "The other cutest Discord client mod",
|
||||||
"homepage": "https://github.com/Equicord/Equicord#readme",
|
"homepage": "https://github.com/Equicord/Equicord#readme",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
|
|
|
||||||
60
src/plugins/_core/fixDiscordCss.ts
Normal file
60
src/plugins/_core/fixDiscordCss.ts
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2026 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import { Logger } from "@utils/Logger";
|
||||||
|
import definePlugin, { StartAt } from "@utils/types";
|
||||||
|
|
||||||
|
let observer: MutationObserver | null;
|
||||||
|
|
||||||
|
function cleanSheet(sheet: CSSStyleSheet) {
|
||||||
|
try {
|
||||||
|
const rules = sheet.cssRules;
|
||||||
|
if (!rules) return;
|
||||||
|
|
||||||
|
for (let i = 0; i < rules.length; i++) {
|
||||||
|
const rule = rules[i];
|
||||||
|
|
||||||
|
if ((rule as CSSStyleRule).selectorText?.includes(":has(.gameOption_")) {
|
||||||
|
new Logger("FixDiscordCss").info("Removed problematic CSS rule", rule.cssText);
|
||||||
|
sheet.deleteRule(i);
|
||||||
|
observer!.disconnect();
|
||||||
|
observer = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleNode(node: Node) {
|
||||||
|
if (node.nodeType !== Node.ELEMENT_NODE || !(node as HTMLElement).matches('link[rel="stylesheet"]')) return;
|
||||||
|
|
||||||
|
const linkNode = node as HTMLLinkElement;
|
||||||
|
|
||||||
|
if (linkNode.sheet) {
|
||||||
|
cleanSheet(linkNode.sheet);
|
||||||
|
} else {
|
||||||
|
node.addEventListener("load", () => cleanSheet(linkNode.sheet!), { once: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "FixDiscordCss",
|
||||||
|
description: "Fixes Discord's css lag",
|
||||||
|
authors: [Devs.Ven],
|
||||||
|
required: true,
|
||||||
|
|
||||||
|
startAt: StartAt.DOMContentLoaded,
|
||||||
|
|
||||||
|
start() {
|
||||||
|
observer = new MutationObserver(mutations => {
|
||||||
|
for (const m of mutations) {
|
||||||
|
m.addedNodes.forEach(handleNode);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
observer.observe(document.head, { childList: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
Loading…
Add table
Reference in a new issue