User:Stumblean/common.js: Difference between revisions
Appearance
No edit summary Tags: Mobile edit Mobile web edit Advanced mobile edit |
No edit summary Tags: Mobile edit Mobile web edit Advanced mobile edit |
||
Line 2: | Line 2: | ||
const iconURL = "https://files.catbox.moe/wk78nl.jpg"; | const iconURL = "https://files.catbox.moe/wk78nl.jpg"; | ||
// === MENU | // === MENU === | ||
const menu = document.createElement("div"); | const menu = document.createElement("div"); | ||
menu.id = "mahitoMenu"; | |||
Object.assign(menu.style, { | Object.assign(menu.style, { | ||
position: "fixed", | position: "fixed", | ||
Line 16: | Line 17: | ||
zIndex: "99999", | zIndex: "99999", | ||
boxShadow: "0 0 10px black", | boxShadow: "0 0 10px black", | ||
width: "180px" | |||
width: "180px" | |||
}); | }); | ||
const header = document.createElement("div"); | const header = document.createElement("div"); | ||
header.style.display = "flex"; | header.style.display = "flex"; | ||
header.style.justifyContent = "space-between"; | |||
header.style.alignItems = "center"; | header.style.alignItems = "center"; | ||
header.style.marginBottom = "8px"; | header.style.marginBottom = "8px"; | ||
const title = document.createElement("div"); | const title = document.createElement("div"); | ||
Line 61: | Line 30: | ||
title.style.fontWeight = "bold"; | title.style.fontWeight = "bold"; | ||
title.style.color = "#fff"; | title.style.color = "#fff"; | ||
const minimizeBtn = document.createElement("button"); | const minimizeBtn = document.createElement("button"); | ||
minimizeBtn.textContent = "–"; | minimizeBtn.textContent = "–"; | ||
minimizeBtn.style.background = "#45A8C5"; | |||
minimizeBtn.style.border = "none"; | |||
minimizeBtn.style.color = "#fff"; | |||
minimizeBtn.style.cursor = "pointer"; | |||
minimizeBtn.style.borderRadius = "5px"; | |||
minimizeBtn.style.width = "25px"; | |||
minimizeBtn.style.height = "25px"; | |||
minimizeBtn | |||
header.appendChild( | header.appendChild(title); | ||
header.appendChild(minimizeBtn); | header.appendChild(minimizeBtn); | ||
// === | // === MINIMIZED ICON === | ||
const minimizedIcon = document.createElement("img"); | |||
minimizedIcon.src = iconURL; | |||
minimizedIcon.width = 30; | |||
minimizedIcon.height = 30; | |||
Object.assign(minimizedIcon.style, { | |||
position: "fixed", | |||
top: "20px", | |||
right: "20px", | |||
zIndex: "99999", | |||
display: "none", | |||
cursor: "pointer" | |||
}); | }); | ||
const | // === Button example (can add more) | ||
const btn = document.createElement("button"); | |||
btn.textContent = "Open Explanation"; | |||
Object.assign(btn.style, { | |||
background: "#45A8C5", | |||
color: "#fff", | |||
border: "none", | |||
padding: "5px 10px", | |||
borderRadius: "5px", | |||
width: "100%", | |||
cursor: "pointer" | |||
}); | }); | ||
// === | // === Append everything | ||
menu.appendChild(header); | menu.appendChild(header); | ||
menu.appendChild( | menu.appendChild(btn); | ||
document.body.appendChild(menu); | document.body.appendChild(menu); | ||
document.body.appendChild(minimizedIcon); | document.body.appendChild(minimizedIcon); | ||
// === | // === Minimize/restore logic | ||
minimizeBtn.addEventListener("click", () => { | |||
menu.style.display = "none"; | |||
minimizedIcon.style.display = "block"; | |||
}); | |||
minimizedIcon.addEventListener("click", () => { | |||
minimizedIcon.style.display = "none"; | |||
menu.style.display = "block"; | |||
menu.style. | |||
}); | }); | ||
})(); | })(); |
Revision as of 21:26, 27 June 2025
(function () {
const iconURL = "https://files.catbox.moe/wk78nl.jpg";
// === MENU ===
const menu = document.createElement("div");
menu.id = "mahitoMenu";
Object.assign(menu.style, {
position: "fixed",
top: "20px",
right: "20px",
background: "#7889B2",
color: "#fff",
border: "2px solid #fff",
borderRadius: "10px",
padding: "10px",
fontFamily: "monospace",
zIndex: "99999",
boxShadow: "0 0 10px black",
width: "180px"
});
const header = document.createElement("div");
header.style.display = "flex";
header.style.justifyContent = "space-between";
header.style.alignItems = "center";
header.style.marginBottom = "8px";
const title = document.createElement("div");
title.textContent = "Mahito Menu";
title.style.fontWeight = "bold";
title.style.color = "#fff";
const minimizeBtn = document.createElement("button");
minimizeBtn.textContent = "–";
minimizeBtn.style.background = "#45A8C5";
minimizeBtn.style.border = "none";
minimizeBtn.style.color = "#fff";
minimizeBtn.style.cursor = "pointer";
minimizeBtn.style.borderRadius = "5px";
minimizeBtn.style.width = "25px";
minimizeBtn.style.height = "25px";
header.appendChild(title);
header.appendChild(minimizeBtn);
// === MINIMIZED ICON ===
const minimizedIcon = document.createElement("img");
minimizedIcon.src = iconURL;
minimizedIcon.width = 30;
minimizedIcon.height = 30;
Object.assign(minimizedIcon.style, {
position: "fixed",
top: "20px",
right: "20px",
zIndex: "99999",
display: "none",
cursor: "pointer"
});
// === Button example (can add more)
const btn = document.createElement("button");
btn.textContent = "Open Explanation";
Object.assign(btn.style, {
background: "#45A8C5",
color: "#fff",
border: "none",
padding: "5px 10px",
borderRadius: "5px",
width: "100%",
cursor: "pointer"
});
// === Append everything
menu.appendChild(header);
menu.appendChild(btn);
document.body.appendChild(menu);
document.body.appendChild(minimizedIcon);
// === Minimize/restore logic
minimizeBtn.addEventListener("click", () => {
menu.style.display = "none";
minimizedIcon.style.display = "block";
});
minimizedIcon.addEventListener("click", () => {
minimizedIcon.style.display = "none";
menu.style.display = "block";
});
})();