Fix Monaco

This commit is contained in:
thororen1234 2024-06-22 09:59:51 -04:00
commit a40ef29b3a
6 changed files with 74 additions and 40 deletions

View file

@ -2,23 +2,22 @@ if (typeof browser === "undefined") {
var browser = chrome;
}
const script = document.createElement("script");
script.src = browser.runtime.getURL("dist/Vencord.js");
script.id = "vencord-script";
Object.assign(script.dataset, {
extensionBaseUrl: browser.runtime.getURL(""),
version: browser.runtime.getManifest().version
});
const style = document.createElement("link");
style.type = "text/css";
style.rel = "stylesheet";
style.href = browser.runtime.getURL("dist/Vencord.css");
document.documentElement.append(script);
document.addEventListener(
"DOMContentLoaded",
() => document.documentElement.append(style),
() => {
document.documentElement.append(style);
window.postMessage({
type: "vencord:meta",
meta: {
EXTENSION_VERSION: browser.runtime.getManifest().version,
EXTENSION_BASE_URL: browser.runtime.getURL(""),
}
});
},
{ once: true }
);

View file

@ -18,13 +18,17 @@
"content_scripts": [
{
"run_at": "document_start",
"matches": [
"*://*.discord.com/*"
],
"js": [
"content.js"
],
"all_frames": true
"matches": ["*://*.discord.com/*"],
"js": ["content.js"],
"all_frames": true,
"world": "ISOLATED"
},
{
"run_at": "document_start",
"matches": ["*://*.discord.com/*"],
"js": ["dist/Vencord.js"],
"all_frames": true,
"world": "MAIN"
}
],
"web_accessible_resources": [
@ -47,4 +51,4 @@
}
]
}
}
}

View file

@ -17,13 +17,17 @@
"content_scripts": [
{
"run_at": "document_start",
"matches": [
"*://*.discord.com/*"
],
"js": [
"content.js"
],
"all_frames": true
"matches": ["*://*.discord.com/*"],
"js": ["content.js"],
"all_frames": true,
"world": "ISOLATED"
},
{
"run_at": "document_start",
"matches": ["*://*.discord.com/*"],
"js": ["dist/Vencord.js"],
"all_frames": true,
"world": "MAIN"
}
],
"background": {
@ -41,4 +45,4 @@
"strict_min_version": "91.0"
}
}
}
}

View file

@ -1,7 +1,7 @@
{
"name": "vencord",
"private": "true",
"version": "1.9.0",
"version": "1.9.1",
"description": "The other cutest Discord client mod",
"homepage": "https://github.com/Equicord/Equicord#readme",
"bugs": {

View file

@ -4,6 +4,9 @@
<head>
<meta charset="utf-8" />
<title>Equicord QuickCSS Editor</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/monaco-editor@0.50.0/min/vs/editor/editor.main.css"
integrity="sha256-tiJPQ2O04z/pZ/AwdyIghrOMzewf+PIvEl1YKbQvsZk=" crossorigin="anonymous"
referrerpolicy="no-referrer" />
<style>
html,
body,
@ -22,18 +25,37 @@
<body>
<div id="container"></div>
<script src="https://cdn.jsdelivr.net/npm/monaco-editor@0.50.0/min/vs/loader.js"
integrity="sha256-KcU48TGr84r7unF7J5IgBo95aeVrEbrGe04S7TcFUjs=" crossorigin="anonymous"
referrerpolicy="no-referrer"></script>
<script>
const script = document.createElement("script");
script.src = new URL("/dist/monaco/index.js", baseUrl);
require.config({
paths: {
vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.50.0/min/vs",
},
});
const style = document.createElement("link");
style.type = "text/css";
style.rel = "stylesheet";
style.href = new URL("/dist/monaco/index.css", baseUrl);
document.body.append(style, script);
require(["vs/editor/editor.main"], () => {
getCurrentCss().then((css) => {
var editor = monaco.editor.create(
document.getElementById("container"),
{
value: css,
language: "css",
theme: getTheme(),
}
);
editor.onDidChangeModelContent(() =>
setCss(editor.getValue())
);
window.addEventListener("resize", () => {
// make monaco re-layout
editor.layout();
});
});
});
</script>
</body>
</html>
</html>

View file

@ -8,7 +8,12 @@ export let EXTENSION_BASE_URL: string;
export let EXTENSION_VERSION: string;
if (IS_EXTENSION) {
const script = document.querySelector("#vencord-script") as HTMLScriptElement;
EXTENSION_BASE_URL = script.dataset.extensionBaseUrl!;
EXTENSION_VERSION = script.dataset.version!;
const listener = (e: MessageEvent) => {
if (e.data?.type === "vencord:meta") {
({ EXTENSION_BASE_URL, EXTENSION_VERSION } = e.data.meta);
window.removeEventListener("message", listener);
}
};
window.addEventListener("message", listener);
}