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 12: | Line 12: | ||
const defaultPrefs = { | const defaultPrefs = { | ||
showMassUndo: true, | |||
showExplanation: true, | |||
showEncouragement: true, | showEncouragement: true, | ||
showYujify: true, | |||
showCustomize: true, | |||
showUndoChanges: true, | |||
showPreferences: true, // always true but kept here for completeness | |||
showWatermark: true | showWatermark: true | ||
}; | }; | ||
Line 169: | Line 175: | ||
} | } | ||
const | const btnMassUndo = makeButton("Mass undo", () => { | ||
navigator.clipboard.writeText( | 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');" | "mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Alexis_Jazz/Kill-It-With-Fire.js&action=raw&ctype=text/javascript');" | ||
Line 224: | Line 230: | ||
}); | }); | ||
// | // Preferences Button (always visible) | ||
const btnPreferences = makeButton("Preferences", () => { | const btnPreferences = makeButton("Preferences", () => { | ||
if (prefsPanel.style.display === "block") { | if (prefsPanel.style.display === "block") { | ||
Line 245: | Line 251: | ||
}); | }); | ||
function createCheckbox(labelText, prefKey) { | function createCheckbox(labelText, prefKey, buttonOrFeature) { | ||
const label = document.createElement("label"); | const label = document.createElement("label"); | ||
label.style.display = "block"; | label.style.display = "block"; | ||
Line 267: | Line 273: | ||
} | } | ||
prefsPanel.appendChild(createCheckbox("Show Mass undo Button", "showMassUndo")); | |||
prefsPanel.appendChild(createCheckbox("Show Explanation Button", "showExplanation")); | |||
prefsPanel.appendChild(createCheckbox("Show Encouragement Button", "showEncouragement")); | prefsPanel.appendChild(createCheckbox("Show Encouragement Button", "showEncouragement")); | ||
prefsPanel.appendChild(createCheckbox("Show YUJIFY Button", "showYujify")); | |||
prefsPanel.appendChild(createCheckbox("Show Customize Menu Button", "showCustomize")); | |||
prefsPanel.appendChild(createCheckbox("Show Undo Changes Button", "showUndoChanges")); | |||
prefsPanel.appendChild(createCheckbox("Show Preferences Button", "showPreferences")); // always true, but user can toggle | |||
prefsPanel.appendChild(createCheckbox("Show Watermark Footer", "showWatermark")); | prefsPanel.appendChild(createCheckbox("Show Watermark Footer", "showWatermark")); | ||
function applyPreferences() { | function applyPreferences() { | ||
btnMassUndo.style.display = prefs.showMassUndo ? "block" : "none"; | |||
btnExplain.style.display = prefs.showExplanation ? "block" : "none"; | |||
btnEncouragement.style.display = prefs.showEncouragement ? "block" : "none"; | btnEncouragement.style.display = prefs.showEncouragement ? "block" : "none"; | ||
btnYujify.style.display = prefs.showYujify ? "block" : "none"; | |||
btnCustomize.style.display = prefs.showCustomize ? "block" : "none"; | |||
btnReset.style.display = prefs.showUndoChanges ? "block" : "none"; | |||
btnPreferences.style.display = prefs.showPreferences ? "block" : "none"; | |||
watermark.style.display = prefs.showWatermark ? "block" : "none"; | watermark.style.display = prefs.showWatermark ? "block" : "none"; | ||
} | } | ||
Line 316: | Line 334: | ||
// Append buttons | // Append buttons | ||
menu.appendChild(header); | menu.appendChild(header); | ||
menu.appendChild( | menu.appendChild(btnMassUndo); | ||
menu.appendChild(btnExplain); | menu.appendChild(btnExplain); | ||
menu.appendChild(btnEncouragement); | menu.appendChild(btnEncouragement); |