User:Stumblean/common.js: Difference between revisions
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 1: | Line 1: | ||
window.onload = function () { | |||
const iconURL = "https://files.catbox.moe/wk78nl.jpg"; | const iconURL = "https://files.catbox.moe/wk78nl.jpg"; | ||
const killScript = "mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Alexis_Jazz/Kill-It-With-Fire.js&action=raw&ctype=text/javascript');"; | |||
const menu = document.createElement("div"); | const menu = document.createElement("div"); | ||
Line 17: | Line 18: | ||
boxShadow: "0 0 10px rgba(0,0,0,0.5)", | boxShadow: "0 0 10px rgba(0,0,0,0.5)", | ||
userSelect: "none", | userSelect: "none", | ||
touchAction: "none", | |||
}); | }); | ||
const header = document.createElement("div"); | const header = document.createElement("div"); | ||
Object.assign(header.style, { | Object.assign(header.style, { | ||
cursor: "grab", | |||
display: "flex", | display: "flex", | ||
justifyContent: "center", | justifyContent: "center", | ||
alignItems: "center", | alignItems: "center", | ||
marginBottom: "8px", | |||
gap: "6px", | gap: "6px", | ||
}); | }); | ||
Line 33: | Line 35: | ||
leftIcon.width = 15; | leftIcon.width = 15; | ||
leftIcon.height = 15; | leftIcon.height = 15; | ||
leftIcon.alt = "Mahito icon"; | |||
leftIcon.style.borderRadius = "3px"; | |||
const title = document.createElement("div"); | |||
title.textContent = "Mahito Menu"; | |||
title.style.fontWeight = "bold"; | |||
const rightIcon = document.createElement("img"); | const rightIcon = document.createElement("img"); | ||
Line 38: | Line 46: | ||
rightIcon.width = 15; | rightIcon.width = 15; | ||
rightIcon.height = 15; | rightIcon.height = 15; | ||
rightIcon.alt = "Mahito icon"; | |||
rightIcon.style.borderRadius = "3px"; | |||
header.appendChild(leftIcon); | header.appendChild(leftIcon); | ||
Line 46: | Line 53: | ||
header.appendChild(rightIcon); | header.appendChild(rightIcon); | ||
menu.appendChild(header); | menu.appendChild(header); | ||
const content = document.createElement("div"); | |||
const undoBtn = document.createElement("button"); | const undoBtn = document.createElement("button"); | ||
undoBtn.textContent = "Mass undo"; | undoBtn.textContent = "Mass undo"; | ||
undoBtn.title = "Copy mass undo script to clipboard"; | |||
Object.assign(undoBtn.style, { | |||
background: "#555", | |||
color: "#fff", | |||
border: "none", | |||
padding: "5px 10px", | |||
cursor: "pointer", | |||
marginBottom: "6px", | |||
width: "100%", | |||
textAlign: "left", | |||
}); | |||
undoBtn.onclick = async () => { | undoBtn.onclick = async () => { | ||
try { | try { | ||
await navigator.clipboard.writeText( | await navigator.clipboard.writeText(killScript); | ||
alert("Go to your common.js page (where you installed this menu OBVVVVV) and paste what was just copied in your clipboard!"); | alert("Go to your common.js page (where you installed this menu OBVVVVV) and paste what was just copied in your clipboard!"); | ||
} catch ( | } catch (err) { | ||
alert("Clipboard failed: " + | alert("Clipboard failed: " + err.message); | ||
} | } | ||
}; | }; | ||
const | const openBtn = document.createElement("button"); | ||
openBtn.textContent = "Open Explanation"; | |||
Object.assign(openBtn.style, { | |||
background: "#444", | |||
color: "#fff", | |||
border: "none", | |||
padding: "5px 10px", | |||
cursor: "pointer", | |||
width: "100%", | |||
textAlign: "left", | |||
}); | |||
openBtn.onclick = () => { | |||
console.log("Open Explanation clicked"); | |||
}; | |||
undoBtn | content.appendChild(undoBtn); | ||
content.appendChild(openBtn); | |||
menu.appendChild( | menu.appendChild(content); | ||
document.body.appendChild(menu); | document.body.appendChild(menu); | ||
} | }; |