Jump to content

User:Stumblean/common.js: Difference between revisions

From Domination Earth
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 89: Line 89:
     display: "none",
     display: "none",
     cursor: "pointer",
     cursor: "pointer",
     borderRadius: "6px",
     borderRadius: "6px", // rounded square
     width: settings.minimizedSize + "px",
     width: settings.minimizedSize + "px",
     height: settings.minimizedSize + "px"
     height: settings.minimizedSize + "px"
Line 163: Line 163:
     saveSettings();
     saveSettings();
     alert("Changes saved! Refresh to apply.");
     alert("Changes saved! Refresh to apply.");
  });
  const btnReset = makeButton("Undo Changes", () => {
    const confirmReset = confirm("Are you sure you want to undo all customizations?");
    if (!confirmReset) return;
    localStorage.removeItem("mahitoMenuSettings");
    alert("Customizations reset! Reloading...");
    location.reload();
   });
   });


Line 195: Line 204:
   menu.appendChild(btnYujify);
   menu.appendChild(btnYujify);
   menu.appendChild(btnCustomize);
   menu.appendChild(btnCustomize);
  menu.appendChild(btnReset);
   document.body.appendChild(menu);
   document.body.appendChild(menu);
   document.body.appendChild(minimizedIcon);
   document.body.appendChild(minimizedIcon);
   document.body.appendChild(ytContainer);
   document.body.appendChild(ytContainer);
})();
})();

Revision as of 18:02, 28 June 2025

(function () {
  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));
  }

  const menu = document.createElement("div");
  menu.id = "mahitoMenu";
  Object.assign(menu.style, {
    position: "fixed",
    top: "20px",
    right: "20px",
    background: settings.backgroundColor,
    color: settings.textColor,
    border: `2px solid ${settings.borderColor}`,
    borderRadius: "10px",
    padding: "10px",
    fontFamily: "monospace",
    zIndex: "99999",
    boxShadow: "0 0 10px black",
    width: "200px",
    userSelect: "none"
  });

  const header = document.createElement("div");
  header.style.display = "flex";
  header.style.justifyContent = "space-between";
  header.style.alignItems = "center";
  header.style.marginBottom = "8px";

  const titleWrap = document.createElement("div");
  titleWrap.style.display = "flex";
  titleWrap.style.alignItems = "center";
  titleWrap.style.gap = "6px";

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

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

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

  titleWrap.appendChild(leftIcon);
  titleWrap.appendChild(title);
  titleWrap.appendChild(rightIcon);

  const minimizeBtn = document.createElement("button");
  minimizeBtn.textContent = "–";
  Object.assign(minimizeBtn.style, {
    background: settings.buttonColor,
    border: "none",
    color: settings.textColor,
    cursor: "pointer",
    borderRadius: "5px",
    width: "25px",
    height: "25px"
  });

  header.appendChild(titleWrap);
  header.appendChild(minimizeBtn);

  const minimizedIcon = document.createElement("img");
  minimizedIcon.src = settings.iconURL;
  Object.assign(minimizedIcon.style, {
    position: "fixed",
    top: "20px",
    right: "20px",
    zIndex: "99999",
    display: "none",
    cursor: "pointer",
    borderRadius: "6px", // rounded square
    width: settings.minimizedSize + "px",
    height: settings.minimizedSize + "px"
  });

  minimizedIcon.addEventListener("click", () => {
    minimizedIcon.style.display = "none";
    menu.style.display = "block";
  });

  minimizeBtn.addEventListener("click", () => {
    menu.style.display = "none";
    minimizedIcon.style.display = "block";
  });

  function makeButton(text, action) {
    const btn = document.createElement("button");
    btn.textContent = text;
    btn.onclick = action;
    Object.assign(btn.style, {
      marginBottom: "6px",
      width: "100%",
      cursor: "pointer",
      background: settings.buttonColor,
      color: settings.textColor,
      border: "none",
      padding: "5px 10px",
      borderRadius: "5px"
    });
    return btn;
  }

  const btnUndo = makeButton("Mass undo", () => {
    navigator.clipboard.writeText(
      "mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Alexis_Jazz/Kill-It-With-Fire.js&action=raw&ctype=text/javascript');"
    );
    alert("Go to your common.js and paste what was just copied!");
  });

  const btnExplain = makeButton("Open Explanation", () => {
    alert("This would explain how Mahito works. You can hook this later.");
  });

  const btnEncouragement = makeButton("Encouragement", () => {
    ytContainer.style.display = ytContainer.style.display === "none" ? "block" : "none";
  });

  const btnYujify = makeButton("YUJIFY", () => {
    const confirmKill = confirm("Are you sure you want to YUJIFY this menu? This will kill the script.");
    if (!confirmKill) return;

    console.log("I'll admit it, mahito, I am you. (script killed)");
    menu.remove();
    minimizedIcon.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.");
  });

  const btnReset = makeButton("Undo Changes", () => {
    const confirmReset = confirm("Are you sure you want to undo all customizations?");
    if (!confirmReset) return;

    localStorage.removeItem("mahitoMenuSettings");
    alert("Customizations reset! Reloading...");
    location.reload();
  });

  const ytContainer = document.createElement("div");
  Object.assign(ytContainer.style, {
    position: "fixed",
    right: "20px",
    top: "150px",
    zIndex: "99998",
    display: "none",
    background: "#000",
    padding: "5px",
    borderRadius: "10px",
    boxShadow: "0 0 10px black"
  });

  const ytIframe = document.createElement("iframe");
  ytIframe.width = "280";
  ytIframe.height = "157";
  ytIframe.src = "https://www.youtube.com/embed/VKfyq_hOL0c?autoplay=1";
  ytIframe.title = "Self Embodiment of Perfection OST";
  ytIframe.frameBorder = "0";
  ytIframe.allow = "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";
  ytIframe.allowFullscreen = true;
  ytContainer.appendChild(ytIframe);

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