Jump to content

User:Stumblean/common.js: Difference between revisions

Stumblean (talk | contribs)
No edit summary
Tags: Mobile edit Mobile web edit Advanced mobile edit
Stumblean (talk | contribs)
No edit summary
Tags: Mobile edit Mobile web edit Advanced mobile edit
Line 1: Line 1:
(function () {
(function () {
   const iconURL = "https://files.catbox.moe/wk78nl.jpg";
   const defaultSettings = {
    menuTitle: "Mahito Menu",
    iconURL: "https://files.catbox.moe/wk78nl.jpg",
    backgroundColor: "#7889B2",
    buttonColor: "#45A8C5",
    textColor: "#ffffff",
    borderColor: "#ffffff",
    iconSize: 15,
    minimizedSize: 30
  };
 
  const settings = JSON.parse(localStorage.getItem("mahitoMenuSettings")) || defaultSettings;
 
  function saveSettings() {
    localStorage.setItem("mahitoMenuSettings", JSON.stringify(settings));
  }


  // === MENU ===
   const menu = document.createElement("div");
   const menu = document.createElement("div");
   menu.id = "mahitoMenu";
   menu.id = "mahitoMenu";
Line 9: Line 23:
     top: "20px",
     top: "20px",
     right: "20px",
     right: "20px",
     background: "#7889B2",
     background: settings.backgroundColor,
     color: "#fff",
     color: settings.textColor,
     border: "2px solid #fff",
     border: `2px solid ${settings.borderColor}`,
     borderRadius: "10px",
     borderRadius: "10px",
     padding: "10px",
     padding: "10px",
Line 17: Line 31:
     zIndex: "99999",
     zIndex: "99999",
     boxShadow: "0 0 10px black",
     boxShadow: "0 0 10px black",
     width: "180px",
     width: "200px",
     userSelect: "none"
     userSelect: "none"
   });
   });


  // === HEADER WITH ICONS AND MINIMIZE BUTTON ===
   const header = document.createElement("div");
   const header = document.createElement("div");
   header.style.display = "flex";
   header.style.display = "flex";
Line 34: Line 47:


   const leftIcon = document.createElement("img");
   const leftIcon = document.createElement("img");
   leftIcon.src = iconURL;
   leftIcon.src = settings.iconURL;
   leftIcon.width = 15;
   leftIcon.width = settings.iconSize;
   leftIcon.height = 15;
   leftIcon.height = settings.iconSize;


   const title = document.createElement("div");
   const title = document.createElement("div");
   title.textContent = "Mahito Menu";
   title.textContent = settings.menuTitle;
   title.style.fontWeight = "bold";
   title.style.fontWeight = "bold";
   title.style.color = "#fff";
   title.style.color = settings.textColor;


   const rightIcon = document.createElement("img");
   const rightIcon = document.createElement("img");
   rightIcon.src = iconURL;
   rightIcon.src = settings.iconURL;
   rightIcon.width = 15;
   rightIcon.width = settings.iconSize;
   rightIcon.height = 15;
   rightIcon.height = settings.iconSize;


   titleWrap.appendChild(leftIcon);
   titleWrap.appendChild(leftIcon);
Line 55: Line 68:
   minimizeBtn.textContent = "–";
   minimizeBtn.textContent = "–";
   Object.assign(minimizeBtn.style, {
   Object.assign(minimizeBtn.style, {
     background: "#45A8C5",
     background: settings.buttonColor,
     border: "none",
     border: "none",
     color: "#fff",
     color: settings.textColor,
     cursor: "pointer",
     cursor: "pointer",
     borderRadius: "5px",
     borderRadius: "5px",
Line 67: Line 80:
   header.appendChild(minimizeBtn);
   header.appendChild(minimizeBtn);


  // === MINIMIZED ICON ===
   const minimizedIcon = document.createElement("img");
   const minimizedIcon = document.createElement("img");
   minimizedIcon.src = iconURL;
   minimizedIcon.src = settings.iconURL;
  minimizedIcon.width = 30;
  minimizedIcon.height = 30;
   Object.assign(minimizedIcon.style, {
   Object.assign(minimizedIcon.style, {
     position: "fixed",
     position: "fixed",
Line 79: Line 89:
     display: "none",
     display: "none",
     cursor: "pointer",
     cursor: "pointer",
     borderRadius: "6px", // rounded square
     borderRadius: "6px",
     width: "30px",
     width: settings.minimizedSize + "px",
     height: "30px"
     height: settings.minimizedSize + "px"
   });
   });


Line 94: Line 104:
   });
   });


  // === Button creator
   function makeButton(text, action) {
   function makeButton(text, action) {
     const btn = document.createElement("button");
     const btn = document.createElement("button");
Line 103: Line 112:
       width: "100%",
       width: "100%",
       cursor: "pointer",
       cursor: "pointer",
       background: "#45A8C5",
       background: settings.buttonColor,
       color: "#fff",
       color: settings.textColor,
       border: "none",
       border: "none",
       padding: "5px 10px",
       padding: "5px 10px",
Line 112: Line 121:
   }
   }


  // === All buttons
   const btnUndo = makeButton("Mass undo", () => {
   const btnUndo = makeButton("Mass undo", () => {
     navigator.clipboard.writeText(
     navigator.clipboard.writeText(
Line 125: Line 133:


   const btnEncouragement = makeButton("Encouragement", () => {
   const btnEncouragement = makeButton("Encouragement", () => {
     if (ytContainer.style.display === "none") {
     ytContainer.style.display = ytContainer.style.display === "none" ? "block" : "none";
      ytContainer.style.display = "block";
    } else {
      ytContainer.style.display = "none";
      ytIframe.src = ytIframe.src; // reset video
    }
   });
   });


Line 138: Line 141:


     console.log("I'll admit it, mahito, I am you. (script killed)");
     console.log("I'll admit it, mahito, I am you. (script killed)");
     if (menu.parentNode) menu.parentNode.removeChild(menu);
     menu.remove();
     if (minimizedIcon.parentNode) minimizedIcon.parentNode.removeChild(minimizedIcon);
    minimizedIcon.remove();
     if (ytContainer.parentNode) ytContainer.remove();
    ytContainer.remove();
  });
 
  const btnCustomize = makeButton("Customize Menu", () => {
    const newTitle = prompt("New menu title:", settings.menuTitle);
    const newIcon = prompt("New icon URL:", settings.iconURL);
    const newBg = prompt("Background color (hex):", settings.backgroundColor);
    const newBtn = prompt("Button color (hex):", settings.buttonColor);
    const newTxt = prompt("Text color (hex):", settings.textColor);
    const newBorder = prompt("Border color (hex):", settings.borderColor);
 
     if (newTitle) settings.menuTitle = newTitle;
    if (newIcon) settings.iconURL = newIcon;
    if (newBg) settings.backgroundColor = newBg;
    if (newBtn) settings.buttonColor = newBtn;
     if (newTxt) settings.textColor = newTxt;
    if (newBorder) settings.borderColor = newBorder;
 
    saveSettings();
    alert("Changes saved! Refresh to apply.");
   });
   });


  // === YouTube iframe container
   const ytContainer = document.createElement("div");
   const ytContainer = document.createElement("div");
   Object.assign(ytContainer.style, {
   Object.assign(ytContainer.style, {
Line 163: Line 184:
   ytIframe.title = "Self Embodiment of Perfection OST";
   ytIframe.title = "Self Embodiment of Perfection OST";
   ytIframe.frameBorder = "0";
   ytIframe.frameBorder = "0";
   ytIframe.allow =
   ytIframe.allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";
    "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";
   ytIframe.allowFullscreen = true;
   ytIframe.allowFullscreen = true;
   ytContainer.appendChild(ytIframe);
   ytContainer.appendChild(ytIframe);


   // === Final Assembly
   // === Add to page
   menu.appendChild(header);
   menu.appendChild(header);
   menu.appendChild(btnUndo);
   menu.appendChild(btnUndo);
Line 175: Line 194:
   menu.appendChild(btnEncouragement);
   menu.appendChild(btnEncouragement);
   menu.appendChild(btnYujify);
   menu.appendChild(btnYujify);
  menu.appendChild(btnCustomize);
   document.body.appendChild(menu);
   document.body.appendChild(menu);
   document.body.appendChild(minimizedIcon);
   document.body.appendChild(minimizedIcon);
   document.body.appendChild(ytContainer);
   document.body.appendChild(ytContainer);
})();
})();
Cookies help us deliver our services. By using our services, you agree to our use of cookies.