ผู้ใช้:Jutiphan/Scripts/userTabs/monobook.js
จากวิกิพีเดีย สารานุกรมเสรี
< ผู้ใช้:Jutiphan | Scripts | userTabs
หมายเหตุ: หลังจากบันทึกแล้ว, คุณต้องล้างแคชของเบราว์เซอร์เสียก่อน จึงจะเห็นการเปลี่ยนแปลง: Mozilla/Safari/Konqueror: กด Shift ค้าง แล้วกด Reload (หรือ Ctrl-Shift-R), IE: กด Ctrl-F5, Opera: กด F5
//<pre><nowiki>
// ========== เพิ่มป้ายหน้าผู้ใช้+แจ้งตักเตือนอััจฉริยะ ==========
function doWarnTag() {
var text = document.editform.wpTextbox1.value;
var regex = /t-test([1-5]?)|\{\{test([1-5]?)\}\}/ig;
var result = regex.exec(text);
if(result != undefined) {
if(result[1].length == 0) {
no = 2;
} else {
no = eval(result[1]) + 1;
}
text = text.replace(/\{\| ?id=\"t-test([1-5]?)\" (.*\r?\n)*?\|\}|\{\{test([1-5]?)\}\}/,"{{subst:test" + no + "}}");
} else {
no = 1;
text = "{{subst:test}}\n\n" + text;
}
document.editform.wpTextbox1.value = text;
document.editform.wpSummary.value = "ตักเตือนครั้งที่ " + no + " ด้วย[[WP:iScript|สคริปต์จัดให้]]";
document.editform.wpMinoredit.checked = true;
document.editform.submit();
}
function doVandalTag() {
var text = document.editform.wpTextbox1.value;
var regex = /\{\{uw-vandal([1-2]?)\}\}/ig;
var result = regex.exec(text);
if (result != undefined) {
no = eval(result[1]) + 1;
} else {
no = 1;
}
var pName = getParamValue("vanarticle");
if (!pName) {
pName = prompt("กรุณาใส่ชื่อบทความที่ผู้ใช้นี้ได้ก่อกวน (จำเป็น)", "");
if(!pName || pName.length == 0) {
return;
}
}
text = text + "\n{{subst:uw-vandal" + no + "|" + pName + "}} --~~~~";
document.editform.wpTextbox1.value = text;
document.editform.wpSummary.value = "เตือนก่อกวนครั้งที่ " + no + " ด้วย[[WP:iScript|สคริปต์จัดให้]]";
document.editform.wpMinoredit.checked = true;
document.editform.submit();
}
function doWarnDelete() {
var text = document.editform.wpTextbox1.value;
var pName = getParamValue("vanarticle");
if (!pName) {
pName = prompt("กรุณาใส่ชื่อบทความที่ผู้ใช้นี้ได้ทำหน้าว่าง (จำเป็น)", "");
if(!pName || pName.length == 0) {
return;
}
}
text = text + "\n{{subst:uw-delete|" + pName + "}} --~~~~";
document.editform.wpTextbox1.value = text;
document.editform.wpSummary.value = pName + " หน้าว่าง?";
document.editform.submit();
}
function doNothanks() {
if (wgPageName.indexOf(".") >= 0) {
document.editform.wpTextbox1.value = "{{nothanks}}\n\n" + document.editform.wpTextbox1.value;
} else {
var pName = getParamValue("vanarticle");
if (!pName) {
var pName = prompt("กรุณาใส่ชื่อบทความที่อาจละเมิดลิขสิทธิ์ (เว้นว่างและคลิก OK หากจะไม่ระบุ):", "")
if (!pName || pName.length == 0) {
return;
}
}
if (pName.length == 0) {
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + "\n{{subst:nothanks0}} --~~~~"
} else {
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + "\n{{subst:nothanks0|[[" + pName + "]]}} --~~~~"
}
}
document.editform.wpSummary.value = "พูดคุยเรื่องลิขสิทธิ์ด้วย[[WP:iScript|สคริปต์จัดให้]]";
document.editform.wpMinoredit.checked = true;
document.editform.submit();
}
function doWelcome() {
if(iScriptConfig.useMyWelcome) {
document.editform.wpTextbox1.value += "{{subst:ผู้ใช้:" + wgUserName + "/ยินดีต้อนรับ}} --~~~~";
} else {
document.editform.wpTextbox1.value += "{{subst:ยินดีต้อนรับ}} --~~~~";
}
document.editform.wpSummary.value = "ยินดีต้อนรับสู่วิกิพีเดียไทย";
document.editform.wpMinoredit.checked = false;
document.editform.submit();
}
/*
if(forceMyWelcome) {
document.editform.wpTextbox1.value += "{{subst:ผู้ใช้:" + wgUserName + "/ยินดีต้อนรับ}} --~~~~";
} else {
document.body.style.cursor = 'wait';
a = sajax_init_object();
a.open("GET", "http://th.wikipedia.org/w/index.php?title=User:" + encodeURI(wgUserName) + encodeURI("/ยินดีต้อนรับ"), true);
a.onreadystatechange = function() {
if(a.readyState != 4) return;
if(a.responseText.indexOf("var wgArticleId = 0;") >= 0) {
document.editform.wpTextbox1.value += "\n{{subst:ยินดีต้อนรับ}} --~~~~";
} else {
document.editform.wpTextbox1.value += "\n{{subst:ผู้ใช้:" + wgUserName + "/ยินดีต้อนรับ}} --~~~~";
}
};
a.send(null);
document.body.style.cursor = 'auto';
}
*/
// ========================================================
// userTabs
// Main Load Function
//
// User:Jutiphan Created: 10-12-2006
// Replaced: none
// ========================================================
addOnloadHook(function() {
if(wgCanonicalNamespace.indexOf("User_talk") >= 0) {
if (document.title.indexOf("แก้ไข") != -1) {
if (document.URL.lastIndexOf("&iScriptAction=speedyWarn") != -1) {
doWarnTag();
} else if(document.URL.lastIndexOf("&iScriptAction=speedyVandal") != -1) {
doVandalTag();
} else if(document.URL.lastIndexOf("&iScriptAction=speedyWDelete") != -1) {
doWarnDelete();
} else if(document.URL.lastIndexOf("&iScriptAction=speedyNoThanks") != -1) {
doNothanks();
} else if(document.URL.lastIndexOf("&iScriptAction=speedyWelcome") != -1) {
doWelcome();
} else if(document.URL.lastIndexOf("&iScriptAction=welcomeiScript") != -1) {
document.editform.wpTextbox1.value += "\n{{subst:ผู้ใช้:Jutiphan/ต้อนรับสคริปต์จัดให้}} --~~~~";
document.editform.wpSummary.value = "ยินดีต้อนรับ +สคริปต์จัดให้";
document.editform.wpMinoredit.checked = false;
document.editform.submit();
} else if (document.URL.indexOf("&iScriptAction=warnNoImageLicenseMW") != -1) {
var imgName = getParamValue("target")
if(document.editform.wpTextbox1.value.indexOf(imgName) >= 0) {
if(!confirm("ภาพที่คุณต้องการจะแจ้งอาจถูกแจ้งไปก่อนหน้านี้แล้ว คุณแน่ใจว่ายังต้องการแจ้งอีกครั้ง?")) {
return;
}
}
imgName = imgName.replace(/\+/g," ");
document.editform.wpTextbox1.value += "\n{{subst:ต้องการสถานะภาพ|" + imgName + "}} --~~~~";
document.editform.wpSummary.value = "แจ้งภาพที่คุณอัปโหลดต้องการสัญญาอนุญาต";
document.editform.submit();
} else if (document.URL.indexOf("&iScriptAction=warnNoImageLicense") != -1) {
if(document.editform.wpTextbox1.value.indexOf(getParamValue("target")) >= 0) {
if(!confirm("ภาพที่คุณต้องการจะแจ้งอาจถูกแจ้งไปก่อนหน้านี้แล้ว คุณแน่ใจว่ายังต้องการแจ้งอีกครั้ง?")) {
return;
}
}
document.editform.wpTextbox1.value += "\n{{subst:ต้องการสถานะภาพ|" + getParamValue("target") + "}} --~~~~";
document.editform.wpSummary.value = "แจ้งภาพที่คุณอัปโหลดต้องการสถานะภาพ";
document.editform.submit();
} else if (document.URL.indexOf("&iScriptAction=warnInvalidImageLicense") != -1) {
if(document.editform.wpTextbox1.value.indexOf(getParamValue("target")) >= 0) {
if(!confirm("ภาพที่คุณต้องการจะแจ้งอาจถูกแจ้งไปก่อนหน้านี้แล้ว คุณแน่ใจว่ายังต้องการแจ้งอีกครั้ง?")) {
return;
}
}
document.editform.wpTextbox1.value += "\n{{subst:idw-cp|" + getParamValue("target") + "}} --~~~~";
document.editform.wpSummary.value = "แจ้งภาพที่คุณอัปโหลดอาจละเมิดลิขสิทธิ์ หรือติดป้ายสัญญาอนุญาตไม่ถูกต้อง";
//document.editform.submit();
return;
}
}
username = wgTitle.split('/')[0];
//หน้าที่เขียน tab is depreciated. Replaced by default option on the sidebox
//addTab("/wiki/พิเศษ:Contributions/" + username, "หน้าที่เขียน", "ca-log", "ดูหน้าที่เขียน", "");
addTab("http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?dbname=thwiki_p&user=" + username, "สถิติ", "ca-kate", "ดูจำนวนครั้งที่แก้ไข", "");
if(wgIsArticle) {
addTab("javascript:doSpeedyWarn()","Ψเตือน", "ca-swarn","ตักเตือน","");
addTab("javascript:doSpeedyVandal()", "Ψก่อกวน", "ca-svandal", "เตือนก่อกวน", "");
addTab("javascript:doSpeedyNoThanks()","Ψละเมิด", "ca-snothanks","เตือนละเมิดลิขสิทธิ์","");
addTab("javascript:doSpeedyWDelete()","Ψทำ่ว่าง","ca-wdelete","เตือนการทำหน้าว่าง","");
addTab("javascript:doSpeedyWelcome()","♥ต้อนรับ","ca-welcome","ยินดีต้อนรับผู้ใช้","");
if(iScriptConfig.enableTestScripts) {
addTab("javascript:assignToEditForm('welcomeiScript')","♥สคริปต์จัดให้","ca-welcomeiScript","ยินดีต้อนรับผู้ใช้สคริปต์จัดให้","");
}
}
}
});
function doSpeedyWarn() {
//edit page
var title = document.title.substr(0, document.title.lastIndexOf(' - วิกิพีเดีย'));
location.assign("/w/index.php?title=" + title + "&action=edit&iScriptAction=speedyWarn");
}
function doSpeedyVandal() {
//edit page
var title = document.title.substr(0, document.title.lastIndexOf(' - วิกิพีเดีย'));
location.assign("/w/index.php?title=" + title + "&action=edit&iScriptAction=speedyVandal");
}
function doSpeedyWDelete() {
var title = document.title.substr(0, document.title.lastIndexOf(' - วิกิพีเดีย'));
location.assign("/w/index.php?title=" + title + "&action=edit&iScriptAction=doSpeedyWDelete");
}
function doSpeedyNoThanks() {
//edit page
var title = document.title.substr(0, document.title.lastIndexOf(' - วิกิพีเดีย'));
location.assign("/w/index.php?title=" + title + "&action=edit&iScriptAction=speedyNoThanks");
}
function doSpeedyWelcome() {
//edit page
var title = document.title.substr(0, document.title.lastIndexOf(' - วิกิพีเดีย'));
location.assign("/w/index.php?title=" + title + "&action=edit&iScriptAction=speedyWelcome");
}
function addVandalTag() {
addTab("javascript:doWarnTag()","Ψเตือน","ca-warn","ตักเตือนอัจฉริยะ");
addTab("javascript:doVandalTag()", "Ψก่อกวน", "ca-vandal", "เตือนก่อกวน", "");
addTab("javascript:doNothanks()","Ψละเมิด", "ca-nothanks","เตือนละเมิดลิขสิทธิ์","");
addTab("javascript:doWarnDelete()","Ψทำว่าง","ca-wdelete","เตือนการทำหน้าว่าง","");
addTab("javascript:doWelcome()","♥ต้อนรับ","ca-welcome","ยินดีต้อนรับผู้ใช้","");
}
if (document.title.indexOf("แก้ไข ") == 0 && wgCanonicalNamespace.indexOf("User_talk") != -1) {
if (window.addEventListener) window.addEventListener("load", addVandalTag, false);
else if (window.attachEvent) window.attachEvent("onload", addVandalTag);
}
//</nowiki></pre>

