-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.js
More file actions
50 lines (44 loc) · 1.54 KB
/
plugin.js
File metadata and controls
50 lines (44 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Import the plugin metadata from plugin.json
const { name, description, version, enabled } = require("./plugin.json");
// Function to display plugin help information
function stylechangerHelp() {
console.log(`Plugin Name: ${name}`);
console.log(`Description: ${description}`);
console.log(`Version: ${version}`);
console.log(`Enabled: ${enabled}`);
console.log("Core Plugins > Works from the changeStyle(styleTable, selector), selector: (.class) (element) (#id)");
}
// Function to initialize the plugin
function initializeStyleChanger() {
if (enabled) {
console.log(`${name} (v${version}) is now enabled.`);
console.log("Ready for Style Changer!");
// Not need for initializePlugin.
} else {
// Do not change anything if the plugin is disabled
console.log(`${name} is currently disabled.`);
}
}
function changeStyle(styleTable, selector) {
if (enabled) {
// Get the selected elements using the selector
const elements = document.querySelectorAll(selector);
// Apply styles from the styleTable to each element
elements.forEach(element => {
for (const property in styleTable) {
element.style[property] = styleTable[property];
}
});
} else {
console.log("The Plugin is still Disabled.");
}
}
// Example usage of the plugin functions
initializePlugin();
mypluginHelp();
// Export the functions if needed for external use
module.exports = {
stylechangerHelp,
initializeStyleChanger,
changeStyle
};