User:Kowey/monobook.js
Jump to navigation
Jump to search
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
- Mozilla / Firefox / Safari: hold down Shift while clicking Reload, or press Ctrl-Shift-R (Cmd-Shift-R on Apple Mac);
- Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5;
- Konqueror: simply click the Reload button, or press F5;
- Opera users may need to completely clear their cache in Tools→Preferences.
Warning: Malicious code can compromise your account. Page preview will cause your web browser to execute this page's content as code under some skins, including Monobook. If you have any questions about any code you plan to add, you can ask at the appropriate reading room. |
The accompanying .css page for this skin can be added at User:Kowey/monobook.css. |
// welcomeNewUsers.js version 1.3 2007-07-12
//
// a Wiki script to add "welcome" links after links to blank talk pages
//
// author: [[b:User:Webaware]]
var welcomeNewUsers = {
win : null,
text_summary : "Welcome message",
text_message : "{{subst" + ":" + "welcome}} ~" + "~" + "~" + "~",
flag_minorEdit : true,
flag_watch : false,
// open a new window at the user's talk page, and insert a welcome message
WelcomeUser : function(talkPageLk) {
try {
this.win = window.open(talkPageLk, "_blank");
var fn = new Function('{\n'
+ 'var doc = welcomeNewUsers.win.document;\n'
+ 'doc.getElementById("wpSummary").value = "' + this.text_summary.replace(/\"/g, '\\"') + '";\n'
+ 'doc.getElementById("wpTextbox1").value = "' + this.text_message.replace(/\"/g, '\\"') + '";\n'
+ 'doc.getElementById("wpMinoredit").checked = ' + this.flag_minorEdit + ';\n'
+ 'doc.getElementById("wpWatchthis").checked = ' + this.flag_watch + ';\n'
+ 'welcomeNewUsers.win = null;\n'
+ '}');
if (this.win.addEventListener)
this.win.addEventListener("load", fn, false);
else if (this.win.attachEvent)
this.win.attachEvent("onload", fn);
}
catch (e) {
if (this.win) {
this.win.close();
this.win = null;
}
alert("An error occured: " + e);
}
},
// installation of object instance
// add a "welcome!" link wherever there is a talk page link for a named user
Install : function() {
var handler = function() { welcomeNewUsers.WelcomeUser(this.href); return false; };
var lks = document.getElementById('bodyContent').getElementsByTagName('a');
for (var i in lks) {
var l = lks[i];
// match only new page links to valid user names, not IP (anon) users
if (l.className == 'new' && l.href.match(/User_talk:((?!(\d{1,3}\.){3}\d{1,3})).*action=edit/)) {
var newLink = document.createElement("a");
newLink.href = l.href + "§ion=new";
newLink.onclick = handler;
newLink.style.color = 'crimson';
newLink.style.fontWeight = 'bold';
newLink.appendChild(document.createTextNode('welcome!'));
l.parentNode.appendChild(document.createTextNode(' '));
l.parentNode.appendChild(newLink);
}
}
}
};
// hook it into the onload event
$(welcomeNewUsers.Install);