ผู้ใช้:AkiAkira/monobook.js
จากวิกิพีเดีย สารานุกรมเสรี
หมายเหตุ: หลังจากบันทึกแล้ว, คุณต้องล้างแคชของเบราว์เซอร์เสียก่อน จึงจะเห็นการเปลี่ยนแปลง: Mozilla/Safari/Konqueror: กด Shift ค้าง แล้วกด Reload (หรือ Ctrl-Shift-R), IE: กด Ctrl-F5, Opera: กด F5
/* <nowiki> */
function addlilink(tabs, url, name, id, title, key){
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if(id) li.id = id;
li.appendChild(na);
tabs.appendChild(li);
na.accesskey = key;
var pref = 'alt-';
if(((clientPC.indexOf('AppleWebKit')!=-1) && (clientPC.indexOf('spoofer')==-1)) || navigator.userAgent.toLowerCase().indexOf( 'mac' ) != -1 ) pref = 'control-';
if(clientPC.indexOf('opera')!=-1) pref = 'shift-esc-';
if(key && title) na.title = title + ' [' + pref + key + ']';
else if(title) na.title = title;
else if(key) na.title = '[' + pref + key + ']';
return li;
}
function addTab(url, name, id, title, key){
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlilink(tabs, url, name, id, title, key);
}
function getPname() {
z=document.getElementById("content").childNodes;
for (var n=0;n<z.length;n++) {
if (z[n].className=="firstHeading") return z[n].textContent;
};
}
// ========== Quick Redirect A.D. --> B.C.==========
function doQwikirdadbc() {
var pagename;
var opname;
opname = getPname(); //Ex "แก้ไข ค.ศ. 32"
pagename= opname.substring(11, opname.length);
pagename = parseInt(pagename);
document.editform.wpTextbox1.value = "#REDIRECT [[พ.ศ. " + (pagename + 543) + "]]" + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = "Add redirect from ค.ศ. " + pagename + " to พ.ศ. " + (pagename + 543);
document.editform.submit();
}
function addQwikirdadbc() {
addTab("javascript:doQwikirdadbc()", "ค.ศ. -> พ.ศ.", "ca-wikird", "โยงค.ศ. ไปหา พ.ศ.", "");
akeytt();
}
if (document.title.indexOf("แก้ไข ") == 0) {
if (window.addEventListener) window.addEventListener("load", addQwikirdadbc, false);
else if (window.attachEvent) window.attachEvent("onload", addQwikirdadbc);
}
// ========== Quick Wikify ==========
function doQwikify() {
document.editform.wpTextbox1.value = "{{ช่วยดูหน่อย}}\n\n" + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = "ช่วยดูหน่อยนะ";
document.editform.wpMinoredit.checked = true;
document.editform.submit();
}
function addQwikify() {
addTab("javascript:doQwikify()", "ช่วย", "ca-wikify", "แจ้งว่าช่วยดูหน่อย", "");
akeytt();
}
if (document.title.indexOf("แก้ไข ") == 0) {
if (window.addEventListener) window.addEventListener("load", addQwikify, false);
else if (window.attachEvent) window.attachEvent("onload", addQwikify);
}
// ========== Quick Speedy delete ==========
function doQsd() {
document.editform.wpTextbox1.value = "{{ลบ}}\n\n" + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = "Marked for speedy deletion.";
document.editform.submit();
}
function addQsd() {
addTab("javascript:doQsd()", "แจ้งลบ", "ca-sd", "คำสั่งแจ้งลบ", "");
akeytt();
}
if (document.title.indexOf("แก้ไข ") == 0) {
if (window.addEventListener) window.addEventListener("load", addQsd, false);
else if (window.attachEvent) window.attachEvent("onload", addQsd);
}
// ========== Edit Section 0 ==========
function addEditSection0() {
ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page'];
if (!document.getElementById) return;
x = document.getElementById('ca-edit');
if(!x) return;
y = document.createElement('LI');
y.id = 'ca-edit-0';
if (x.className == 'selected') {
if (/&action=edit§ion=0$/.test(window.location.href)) {
x.className = 'istalk';
y.className = 'selected';
} else {
x.className = 'selected istalk';
}
} else if (x.className == 'selected istalk') {
if (/&action=edit§ion=0$/.test(window.location.href)) {
x.className = 'istalk';
y.className = 'selected istalk';
} else {
y.className = 'istalk';
}
} else {
y.className = x.className;
x.className = 'istalk';
}
z = document.createElement('A');
if (x.children) {
z.href = x.children[0].href + '§ion=0';
z.appendChild(document.createTextNode('0'));
y.appendChild(z);
document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling);
} else {
z.href = x.childNodes[0].href + '§ion=0';
z.appendChild(document.createTextNode('0'));
y.appendChild(z);
document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling);
}
}
if (document.title.indexOf("Editing ") == -1) {
if (window.addEventListener) window.addEventListener("load", addEditSection0, false);
else if (window.attachEvent) window.attachEvent("onload", addEditSection0);
}
// ========== Add Last Diff ==========
function doLastDiff() {
var nurl="http://th.wikipedia.org/w/index.php?title=" + getPname() + "&diff=cur&oldid=prev";
document.location=nurl
}
function addLastDiff() {
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
var l=addlilink(tabs, "javascript:doLastDiff()", 'ล่าสุด', '');
l.lastChild.title="Show most recent diff";
}
if (window.addEventListener) window.addEventListener("load", addLastDiff, false);
else if (window.attachEvent) window.attachEvent("onload", addLastDiff);
// ========== Quick Thai Page's Name Category ==========
function doATHName() {
var pagename;
var opname;
opname = getPname(); //Ex "แก้ไข เมษายน"
pagename= opname.substring(6, opname.length);
repgn = pagename.substring(2,1) + pagename.substring(0,1) + pagename.substring(2,pagename.length);
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + "[[หมวดหมู่:|"+repgn+"]]";
}
function addATHName() {
addTab("javascript:doATHName()", "ชื่อไทย", "ca-athname", "ชื่อไทย", "");
akeytt();
}
if (document.title.indexOf("แก้ไข ") == 0) {
if (window.addEventListener) window.addEventListener("load", addATHName, false);
else if (window.attachEvent) window.attachEvent("onload", addATHName);
}
/* </nowiki> */

