From cf104fb0f33f061432d70b81d0905a3e385138fc Mon Sep 17 00:00:00 2001 From: Arcane <74067110+MeowArcane@users.noreply.github.com> Date: Sun, 4 Aug 2024 14:23:43 -0400 Subject: [PATCH] Add files via upload --- Plugins/essentials.nkplugin.js | 71 ++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Plugins/essentials.nkplugin.js diff --git a/Plugins/essentials.nkplugin.js b/Plugins/essentials.nkplugin.js new file mode 100644 index 0000000..56ba0b9 --- /dev/null +++ b/Plugins/essentials.nkplugin.js @@ -0,0 +1,71 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +class Essentials { + info = { + name: "Essentials", + id: "arcane:Essentials", + authors: [{ + name: "Arcane", + id: "808802000224518264" + }], + description: "Minor tweaks that make discord better!", + version: "1.0.0", + patches: [], + preferences: [ + { + name: "ArcaneTweaks", + description: "CSS Tweaks called ArcaneTweaks", + id: "ArcaneTweaks", + type: "boolean", + default: true + }, + ] + }; + + constructor(userPreferences) { + this.userPreferences = userPreferences; + } + onPreferencesChange(userPreferences) { + this.userPreferences = userPreferences; + this.tryToEnableTweaks(); + this.enableSitelenPona(); + } + + tryToEnableTweaks() { + if (this.userPreferences.ArcaneTweaks === true) { + const Css = `@import url('https://arcane.kitties.cat/Themes/ArcaneTweaks.nktheme.css');`; + // Ensure the DOM is fully loaded before applying CSS + if (document.readyState === 'complete') { + this.applyCss(Css); + } else { + window.addEventListener('load', () => this.applyCss(Css)); + } + } + } + enableSitelenPona() { + const Css = `@import url('https://arcane.kitties.cat/Themes/sitelenpona.nktheme.css');`; + // Ensure the DOM is fully loaded before applying CSS + if (document.readyState === 'complete') { + this.applyCss(Css); + } else { + window.addEventListener('load', () => this.applyCss(Css)); + } + } + // Function to apply css + applyCss(css) { + const styleElement = document.createElement('style'); + styleElement.textContent = css; + + if (document.head) { + document.head.appendChild(styleElement); + console.log(`Essentials: ArcaneTweaks applied successfully`); + } else { + console.error("Essentials: document.head is null or undefined"); + } + } +} +exports.default = Essentials; \ No newline at end of file