User:Sav/welcome.js: Difference between revisions
< User:Sav
Content deleted Content added
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
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'); |
mw.loader.load('/w/index.php?title=User:Sav/welcome.js&action=raw&ctype=text/javascript'); |
||
⚫ | |||
⚫ | |||
if (mw.config.get('wgNamespaceNumber') == 3) { |
if (mw.config.get('wgNamespaceNumber') == 3) { |
||
Line 21: | Line 22: | ||
} |
} |
||
} |
} |
||
// Modified from https://en.scratch-wiki.info/w/index.php?title=User:12944qwerty/welcome.js&oldid=303214 |
|||
console.log("Loaded Wiki Welcome"); |
console.log("Loaded Wiki Welcome"); |
Revision as of 17:10, 13 June 2024
const WELCOME_TEMPLATE = "User:Sav/Welcome";
mw.loader.load('/w/index.php?title=User:Sav/welcome.js&action=raw&ctype=text/javascript');
const tag = "welcomingnice"; // Change this to change the query used to detect if you're welcoming
if (mw.config.get('wgNamespaceNumber') == 3) {
let actions = document.querySelector('.content-actions');
let ul = actions.getElementsByClassName('dropdown')[0];
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.replaceAll("/wiki/", "")) + '&action=edit§ion=new&' + tag + '=true" title="Welcome this user!">Welcome User</a></li>';
if (params.has(tag)) {
$("#wpSummary").textSelection('setContents', 'Welcome!');
$("#wpTextbox1").textSelection('setContents', '{{' + WELCOME_TEMPLATE + '}}~~' + '~~\n');
}
}
// Modified from https://en.scratch-wiki.info/w/index.php?title=User:12944qwerty/welcome.js&oldid=303214
console.log("Loaded Wiki Welcome");