User:Sav/welcome.js: Difference between revisions
< User:Sav
Content deleted Content added
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
// THIS IS A WORK IN PROGRESS, DO NOT INSTALL THIS SCRIPT OR MAKE CHANGES. |
|||
const WELCOME_TEMPLATE = "User:Sav/Welcome"; |
const WELCOME_TEMPLATE = "User:Sav/Welcome"; |
||
⚫ | |||
mw.loader.load('/w/index.php?title=User:Sav/welcome.js&action=raw&ctype=text/javascript'); |
|||
document.addEventListener('DOMContentLoaded', function () { |
|||
⚫ | |||
⚫ | |||
if (actions) { |
|||
⚫ | |||
if (ul) { |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
document.getElementById("wpSummary").value = 'Welcome!'; |
|||
⚫ | |||
⚫ | |||
⚫ | |||
} |
|||
} |
|||
⚫ | |||
} |
|||
⚫ | |||
} |
|||
}); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
$("#wpSummary").textSelection('setContents', 'Welcome!'); |
|||
⚫ | |||
} |
|||
} |
|||
console.log("Loaded Wiki Welcome"); |
console.log("Loaded Wiki Welcome"); |
Latest revision as of 17:42, 31 July 2024
// THIS IS A WORK IN PROGRESS, DO NOT INSTALL THIS SCRIPT OR MAKE CHANGES.
const WELCOME_TEMPLATE = "User:Sav/Welcome";
const tag = "Welcome!"; // Change this to change the query used to detect if you're welcoming
document.addEventListener('DOMContentLoaded', function () {
if (mw.config.get('wgNamespaceNumber') == 3) {
let actions = document.querySelector('.content-actions');
if (actions) {
let ul = actions.getElementsByClassName('dropdown')[0];
if (ul) {
let li = document.createElement('li');
ul.insertBefore(li, document.getElementById('ca-history'));
const params = new URLSearchParams(window.location.search);
li.innerHTML = '<li id="ca-welcome" class="selected"><a href="/w/index.php?title=' + (params.has("title") ? params.get("title") : window.location.pathname.replace("/wiki/", "")) + '&action=edit§ion=new&' + tag + '=true" title="Welcome this user!">Welcome User</a></li>';
if (params.has(tag)) {
document.getElementById("wpSummary").value = 'Welcome!';
document.getElementById("wpTextbox1").value = '{{' + WELCOME_TEMPLATE + '}}~~' + '~~\n';
}
}
}
}
});
console.log("Loaded Wiki Welcome");