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 62: | Line 62: | ||
} | } | ||
// -- Always add these two | |||
const btn1 = makeButton("Mass undo", () => { | const btn1 = makeButton("Mass undo", () => { | ||
prompt("Copy this into your common.js:", "mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Alexis_Jazz/Kill-It-With-Fire.js&action=raw&ctype=text/javascript');"); | prompt("Copy this into your common.js:", "mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Alexis_Jazz/Kill-It-With-Fire.js&action=raw&ctype=text/javascript');"); | ||
Line 74: | Line 75: | ||
menu.appendChild(btn2); | menu.appendChild(btn2); | ||
// | // -- Safely check if it's common.js | ||
const | const user = mw.config.get("wgUserName") || ""; | ||
const title = mw.config.get("wgPageName") || ""; | |||
const isCommonJS = title.includes(user + "/common.js"); | |||
if (isCommonJS) { | if (isCommonJS) { | ||
const ezBtn = makeButton("EZPASTE", async () => { | const ezBtn = makeButton("EZPASTE", async () => { | ||
Line 81: | Line 85: | ||
const clip = await navigator.clipboard.readText(); | const clip = await navigator.clipboard.readText(); | ||
await navigator.clipboard.writeText(clip); | await navigator.clipboard.writeText(clip); | ||
alert("EZPASTE: Clipboard refreshed | alert("EZPASTE: Clipboard refreshed with:\n\n" + clip); | ||
} catch (e) { | } catch (e) { | ||
alert("Clipboard failed: " + e.message); | alert("Clipboard failed: " + e.message); |