User:Stumblean/common.js

Revision as of 00:03, 29 June 2025 by Stumblean (talk | contribs)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
(function () {
  // Create toggle button
  const toggle = document.createElement("button");
  toggle.id = "delta-toggle";
  toggle.textContent = "Δ";
  Object.assign(toggle.style, {
    position: "fixed",
    bottom: "20px",
    right: "20px",
    padding: "10px",
    background: "#1e1e1e",
    color: "#fff",
    border: "none",
    borderRadius: "8px",
    zIndex: 9998,
    cursor: "pointer",
    fontSize: "16px"
  });

  // Create menu
  const menu = document.createElement("div");
  menu.id = "delta-menu";
  Object.assign(menu.style, {
    display: "none",
    position: "fixed",
    bottom: "70px",
    right: "20px",
    width: "300px",
    background: "#2b2b2b",
    color: "#fff",
    borderRadius: "10px",
    padding: "15px",
    boxShadow: "0 0 10px rgba(0,0,0,0.5)",
    zIndex: 9999,
    fontFamily: "monospace"
  });

  const title = document.createElement("div");
  title.textContent = "Delta Online";
  title.style.textAlign = "center";
  title.style.fontSize = "18px";
  title.style.marginBottom = "10px";

  const textarea = document.createElement("textarea");
  textarea.placeholder = "Enter JavaScript...";
  Object.assign(textarea.style, {
    width: "100%",
    height: "120px",
    background: "#1e1e1e",
    color: "#fff",
    border: "none",
    borderRadius: "6px",
    padding: "10px",
    resize: "none",
    boxSizing: "border-box"
  });

  const runBtn = document.createElement("button");
  runBtn.textContent = "Run Code";
  Object.assign(runBtn.style, {
    marginTop: "10px",
    width: "100%",
    padding: "10px",
    background: "#4caf50",
    color: "#fff",
    border: "none",
    borderRadius: "6px",
    cursor: "pointer"
  });

  runBtn.onclick = () => {
    try {
      new Function(textarea.value)();
    } catch (e) {
      alert("Error: " + e.message);
    }
  };

  toggle.onclick = () => {
    menu.style.display = menu.style.display === "none" ? "block" : "none";
  };

  // Assemble the UI
  menu.appendChild(title);
  menu.appendChild(textarea);
  menu.appendChild(runBtn);
  document.body.appendChild(toggle);
  document.body.appendChild(menu);
})();