User:Microchip08/monobook.js
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)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/**
* A function from [[wikt:en:User:Visviva/pretext.js]] to allow arbitrary
* text to be inserted into the edit box through the URL.
*
* Visit a url of the form ?action=edit&preloadtext=<something>&preloadsummary=
*/
function preloadText() {
var pretext=""
var presummary=""
try {
parts=window.location.search.split("?")[1].split("&")
} catch (e) {
return; //not an edit page
}
for (p in parts) {
pair=parts[p].split("=")
if (pair[0]=="preloadtext") {
pretext=unescape(pair[1])
}else if (pair[0]=="preloadsummary") {
presummary=unescape(pair[1])
}
}
if (pretext != ""){
if (document.editform.wpTextbox1.value != ""){
pretext+="\n\n"
}
pretext=pretext+document.editform.wpTextbox1.value
document.editform.wpTextbox1.value=pretext
}
if (presummary != "") {
document.editform.wpSummary.value += presummary;
}
}
addOnloadHook( preloadText );