Skip to content

Commit

Permalink
Major Rewrite, tweaks are now added via a function call instead of be…
Browse files Browse the repository at this point in the history
…ing seperated

throught many files.

Some tweaks may be missing, leave a issue if a tweak is missing or broken!!
  • Loading branch information
M0chaCat committed Dec 25, 2024
1 parent d72cab4 commit abc4735
Show file tree
Hide file tree
Showing 25 changed files with 1,397 additions and 2,109 deletions.
46 changes: 30 additions & 16 deletions Essentials.nkplugin.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ Object.defineProperty(exports, "__esModule", {
});
exports.default = void 0;

const { cssThemes } = require('./cssThemes');
const QuickCSSTab = require('./QuickCSSTab');
const M0chaTweaksTab = require('./components/M0chaTweaksTab');
const { ThemeImportTab, applyThemeUrls } = require('./ThemeImportTab');


const QuickCSSTab = require("./QuickCSSTab");
const M0chaTweaksTab = require("./components/M0chaTweaksTab");
const { ThemeImportTab, applyThemeUrls } = require("./ThemeImportTab");
const tweaks = require("./tweaks");

/*
Expand All @@ -24,13 +22,10 @@ find . -type f \( -name "*.js" -o -name "*.jsx" -o -name "*.css" \) -not -path "
*/



class Essentials {
constructor(userPreferences) {
this.userPreferences = userPreferences;
this.cssThemes = cssThemes;


// Apply theme imports on startup
const savedThemeUrls = NekocordNative.preferences.getForPlugin(
"cat.kitties.arcane.Essentials",
Expand Down Expand Up @@ -76,8 +71,6 @@ class Essentials {
this.tryToEnableTweaks();
}



tryToEnableTweaks() {
// Get the saved settings from preferences
const savedPrefs = NekocordNative.preferences.getForPlugin(
Expand Down Expand Up @@ -129,13 +122,13 @@ class Essentials {

// Check each setting and apply CSS only for enabled settings
if (savedPrefs) {
Object.entries(savedPrefs).forEach(([key, value]) => {
if (value === true && this.cssThemes[key]) {
tweaks.forEach((tweak) => {
if (savedPrefs[tweak.id]) {
if (document.readyState === "complete") {
this.applyCss(this.cssThemes[key], `essentials-${key}`);
this.applyCss(tweak.css, `essentials-${tweak.id}`);
} else {
window.addEventListener("load", () =>
this.applyCss(this.cssThemes[key], `essentials-${key}`),
this.applyCss(tweak.css, `essentials-${tweak.id}`),
);
}
}
Expand Down Expand Up @@ -186,5 +179,26 @@ class Essentials {
element: ThemeImportTab,
},
};

start() {
// Listen for settings changes
window.addEventListener("essentials-settings-changed", () => {
const settings = NekocordNative.preferences.getForPlugin(
"cat.kitties.arcane.Essentials",
"settings",
);

// Apply CSS for enabled tweaks
tweaks.forEach((tweak) => {
if (settings[tweak.id]) {
this.applyCss(tweak.css, `essentials-${tweak.id}`);
} else {
// Remove CSS if tweak is disabled
const element = document.getElementById(`essentials-${tweak.id}`);
if (element) element.remove();
}
});
});
}
}
exports.default = Essentials;
2 changes: 1 addition & 1 deletion PreviewModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ function PreviewModal({ previewBefore, previewAfter, onClose }) {
);
}

module.exports = PreviewModal;
module.exports = PreviewModal;
81 changes: 54 additions & 27 deletions QuickCSSTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,33 @@ function QuickCSSTab() {
<SectionHeader title="QuickCSS" />

<div className="header-container" style={{ marginBottom: "24px" }}>
<div className="defaultColor_a595eb text-md/normal_dc00ef"
style={{ opacity: 0.8, lineHeight: "1.5" }}>
<div
className="defaultColor_a595eb text-md/normal_dc00ef"
style={{ opacity: 0.8, lineHeight: "1.5" }}
>
<p>Add custom CSS snippets here. Changes apply instantly.</p>
<p style={{
color: "var(--brand-experiment)",
fontSize: "13px",
marginTop: "4px",
fontStyle: "italic"
}}>
{''}
<p
style={{
color: "var(--brand-experiment)",
fontSize: "13px",
marginTop: "4px",
fontStyle: "italic",
}}
>
{""}
</p>
</div>
</div>

<div className="button-container"
style={{
display: "flex",
gap: "8px",
marginBottom: "16px",
justifyContent: "flex-end"
}}>
<div
className="button-container"
style={{
display: "flex",
gap: "8px",
marginBottom: "16px",
justifyContent: "flex-end",
}}
>
<button
onClick={handleClear}
className="button-f14gos"
Expand All @@ -107,17 +113,38 @@ function QuickCSSTab() {

<div className="codeContainer_f8f345">
<div className="codeActions_f8f345">
<div
className="copyButton"
role="button"
tabIndex="0"
<div
className="copyButton"
role="button"
tabIndex="0"
onClick={handleCopy}
style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}
style={{
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
<svg aria-hidden="true" role="img" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 24 24">
<path fill="currentColor" d="M3 16a1 1 0 0 1-1-1v-5a8 8 0 0 1 8-8h5a1 1 0 0 1 1 1v.5a.5.5 0 0 1-.5.5H10a6 6 0 0 0-6 6v5.5a.5.5 0 0 1-.5.5H3Z"></path>
<path fill="currentColor" d="M6 18a4 4 0 0 0 4 4h8a4 4 0 0 0 4-4v-4h-3a5 5 0 0 1-5-5V6h-4a4 4 0 0 0-4 4v8Z"></path>
<path fill="currentColor" d="M21.73 12a3 3 0 0 0-.6-.88l-4.25-4.24a3 3 0 0 0-.88-.61V9a3 3 0 0 0 3 3h2.73Z"></path>
<svg
aria-hidden="true"
role="img"
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="none"
viewBox="0 0 24 24"
>
<path
fill="currentColor"
d="M3 16a1 1 0 0 1-1-1v-5a8 8 0 0 1 8-8h5a1 1 0 0 1 1 1v.5a.5.5 0 0 1-.5.5H10a6 6 0 0 0-6 6v5.5a.5.5 0 0 1-.5.5H3Z"
></path>
<path
fill="currentColor"
d="M6 18a4 4 0 0 0 4 4h8a4 4 0 0 0 4-4v-4h-3a5 5 0 0 1-5-5V6h-4a4 4 0 0 0-4 4v8Z"
></path>
<path
fill="currentColor"
d="M21.73 12a3 3 0 0 0-.6-.88l-4.25-4.24a3 3 0 0 0-.88-.61V9a3 3 0 0 0 3 3h2.73Z"
></path>
</svg>
</div>
</div>
Expand All @@ -137,7 +164,7 @@ function QuickCSSTab() {
outline: "none",
fontSize: "14px",
lineHeight: "1.5",
caretColor: "var(--brand-experiment)"
caretColor: "var(--brand-experiment)",
}}
spellCheck="false"
placeholder={`/* Add your custom CSS here */
Expand Down Expand Up @@ -263,4 +290,4 @@ function QuickCSSTab() {
);
}

module.exports = QuickCSSTab;
module.exports = QuickCSSTab;
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Essentials

Many tiny (or big) Discord tweaks, compiled into one giant plugin

# Sections

- M0chaTweaks: Css tweaks
- ill make more soon prolly
- QuickCSS
- Theme Imports, like Vencord!

## Features

- **Core UI Improvements**: Forum enhancements, better appearance settings ui, collapsible message actions
- **Interface Tweaks**: Centered channel names, better emoji/sticker pickers, custom chat bar placeholder text
- **Chat Features**: Custom chat placeholders, IRC-style theme
Expand All @@ -15,18 +19,23 @@ Many tiny (or big) Discord tweaks, compiled into one giant plugin
And many more!

## Installation
1. Install [Nekocord](https://github.com/nekocord-mod/nekocord)

1. Install [Nekocord](https://github.com/nekocord-mod/nekocord)
2. Download the latest release of Essentials
3. Place the plugin in your Nekocord plugins directory

## Building

just run `npm run build` :3

## Contributing

Feel free to suggest new tweaks or improvements by opening an issue or pull request!

## Credits
Created by @m0chacat, and css made by the people of da vencord #css-snippets channel :3

Created by @m0chacat, and css made by the people of da vencord #css-snippets channel :3

## License
idfk just dont sell it for money or anything, also if you fix a bug then pwease make a pull request :3

idfk just dont sell it for money or anything, also if you fix a bug then pwease make a pull request :3
2 changes: 1 addition & 1 deletion SearchBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ function SearchBar({ onSearch }) {
);
}

module.exports = SearchBar;
module.exports = SearchBar;
2 changes: 1 addition & 1 deletion SectionHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ function SectionHeader({ title }) {
);
}

module.exports = SectionHeader;
module.exports = SectionHeader;
2 changes: 1 addition & 1 deletion SettingsToggle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,4 @@ function SettingsToggle({
);
}

module.exports = SettingsToggle;
module.exports = SettingsToggle;
Loading

0 comments on commit abc4735

Please sign in to comment.