ผู้ใช้:Jutiphan/Scripts/cleanup/monobook.js
จากวิกิพีเดีย สารานุกรมเสรี
< ผู้ใช้:Jutiphan | Scripts | cleanup
หมายเหตุ: หลังจากบันทึกแล้ว, คุณต้องล้างแคชของเบราว์เซอร์เสียก่อน จึงจะเห็นการเปลี่ยนแปลง: Mozilla/Safari/Konqueror: กด Shift ค้าง แล้วกด Reload (หรือ Ctrl-Shift-R), IE: กด Ctrl-F5, Opera: กด F5
/* <pre><nowiki> */ // ******************************* // ยกเลิกการใช้งาน // Obsolete 7/1/2007 // Superseded by mainTabs // ******************************* // ========== จัดรูปแบบ+เก็บกวาด ========== // สคริปต์นี้ เปลี่ยนคำสั่งเก่า เช่น Category, Image, และข้อความเก่า function doCleanupTag(isSpeedy) { document.body.style.cursor = 'wait'; text = document.editform.wpTextbox1.value; //Format //text = text.replace(/<br>|<br\/>/gi, "<br />"); //<br/> -> <br /> text = text.replace(/([^\[]|^)\[([^\[^\]]*?)\]\]/gm, "$1[[$2]]"); //[ลิงก์ใน]] -> [[ลิงก์ใน]] text = text.replace(/\[\[([^\[^\]].*?)[$[^\]]?]/gm, "[[$1]]"); //[[ลิงก์ใน] -> [[ลิงก์ใน]] text = text.replace(/\[\[ ?([^\]\|]*?) \s*([\|\s|\]\]])/g, "[[$1$2"); //[ ลิงก์ใน ]] -> [[ลิงก์ใน]] text = text.replace(/^([\*#]+) /gm, "$1"); text = text.replace(/^([\*#]+)/gm, "$1 "); text = text.replace(/^= ?([^=].*?) ?=/gm,"== $1 =="); //= หัวข้อ = -> == หัวข้อ == text = text.replace(/^(={1,4}) *(.*?) ?(={1,4})$/gm, "$1 $2 $3"); //==หัวข้อ== -> == หัวข้อ == text = text.replace(/ /g, " "); text = text.replace(/′/g, "'"); text = text.replace(/&/g, "&"); text = text.replace(/−/g, "−"); text = text.replace(/×/g, "×"); text = text.replace(/—/g, "—"); text = text.replace(/–/g, "-"); //Fix lang icons: Move from front to back text = text.replace(/\* ?({{.*}}) ?([^\r]*)/g,"* $2 $1"); //แก้ * {{...}} [...] -> * [...] {{...}} text = text.replace(/<ref> ?({{.*?}}) ?([^\r]*?) ?<\/ref>/g,"<ref>$2 $1</ref>"); //แก้ <ref> {{...}} [...] </ref> -> <ref>[...] {{...}}</ref> //Fix Template Parameters Layout: Move | from back to front (using Top to Bottom approach) text = text.replace(/ *\|(?!-) *\r\n *([^|{}]*?) ?= *([^|{}]*?)/g,"\r\n| $1 = $2"); //รวมแก้สองอย่างโดยการตรวจย้ายบนไปล่างแทน //text = text.replace(/({{.*)(?!})\| *\r/g,"$1"); //แก้ {{... | -> {{... //text = text.replace(/(\n) *([^|{}]*?) ?= *([^|{}]*?)\| *\r/g,"$1| $2 = $3"); //แก้ ... | -> | ... text = text.replace(/\n *\|(?!-) *([^{}].*?) ?= *([^{}]*?) \| ?( *}} *\r\n| *\r\n *}} *\r\n)/g,"\n| $1 = $2\n}}\n") //รุ่นใหม่ แค่จับขึ้นบรรทัดใหม่ //text = text.replace(/(\n) *([^\|{}].*?) ?= *([^|{}]*?)(}}\r\n|\r\n *}})/g,"$1| $2 = $3\n}}");//แก้ ... -> | ... //Fix Template Parameters Layout: Add extra space inbetweens text = text.replace(/\n *\|(?!-) *([^\|'"{}]*?) ?= *([^=]*?) *\r/g,"\n| $1 = $2"); //Fix Year Formatting text = text.replace(/(พ\.ศ\.|ค\.ศ\.)(\d{1,4})/g,"$1 $2"); //Spellings if(text.indexOf("nofixbot") == -1) { text = text.replace(/\sกฏ/g," กฎ"); text = text.replace(/กรกฏาคม/g, "กรกฎาคม"); text = text.replace(/กราฟฟิค/g,"กราฟฟิก"); text = text.replace(/กิติมศักดิ์/g,"กิตติมศักดิ์"); text = text.replace(/คลีนิก/g,"คลินิก"); text = text.replace(/คำนวน/g,"คำนวณ"); text = text.replace(/โครงการณ์/g,"โครงการ"); text = text.replace(/ซอฟท์แวร์/g,"ซอฟต์แวร์"); text = text.replace(/เซ็นติ/g,"เซนติ"); text = text.replace(/เซอร์เวอร์/g,"เซิร์ฟเวอร์"); text = text.replace(/ฑูต/g,"ทูต"); text = text.replace(/ดอทเน็ท|ดอตเน็ท|ด็อตเน็ต|ด็อทเน็ต/g,"ดอตเน็ต"); text = text.replace(/ดุลย์/g,"ดุล"); text = text.replace(/ธุระกิจ/g,"ธุรกิจ"); text = text.replace(/นิวยอร์ค/g, "นิวยอร์ก"); text = text.replace(/บราวเซอร์|เบราเซอร์/g, "เบราว์เซอร์"); text = text.replace(/ปฎิ/g,"ปฏิ"); text = text.replace(/ปฏิกริยา/g,"ปฏิกิริยา"); text = text.replace(/ปรากฎ/g,"ปรากฏ"); text = text.replace(/ปราถนา/g,"ปรารถนา"); text = text.replace(/ผลลัพท์/g,"ผลลัพธ์"); text = text.replace(/ฝรั่งเศษ/g,"ฝรั่งเศส"); text = text.replace(/มิวสิค/g,"มิวสิก"); text = text.replace(/ไมโครซอฟต์/g,"ไมโครซอฟท์"); text = text.replace(/ร็อค/g,"ร็อก"); text = text.replace(/ลายเซ็นต์/g,"ลายเซ็น"); text = text.replace(/เวทย์มนตร์|เวทมนต์/g,"เวทมนตร์"); text = text.replace(/เวบไซท์|เวบไซต์|เวบไซท์|เว็บไซท์|เว็บไซต(?!\u0E4C)/g, "เว็บไซต์"); text = text.replace(/สคริปท์|สครปต์/g,"สคริปต์"); text = text.replace(/อโดบี/g,"อะโดบี"); text = text.replace(/อนุญาติ/g,"อนุญาต"); text = text.replace(/อลูมิเนียม/g, "อะลูมิเนียม"); text = text.replace(/อัพเด็ต|อัพเดต|อัพเดท|อัปเด็ต/g,"อัปเดต"); text = text.replace(/อินเตอร์เน็ต|อินเตอร์เนต|อินเทอร์เนต/g,"อินเทอร์เน็ต"); text = text.replace(/อิเล็กโทรนิกส์/g, "อิเล็กทรอนิกส์"); text = text.replace(/อิสระภาพ/g,"อิสรภาพ"); text = text.replace(/เอ็กซ์/g,"เอกซ์"); text = text.replace(/แอปพลิเคชั่น|แอพพลิเคชั่น|แอพพลิเคชัน/g, "แอปพลิเคชัน"); //text = text.replace(/เอ็กซเรย์/g, "เอกซเรย์"); //Cleanup text = text.replace(/\[\[category:/gi,'[[หมวดหมู่:'); text = text.replace(/image:/gi,'ภาพ:'); text = text.replace(/template:/gi,'แม่แบบ:'); } text = text.replace(/(== ?) ?(แหล่งอ้างอิง|หนังสืออ้างอิง|เอกสารอ้างอิง|ข้อมูลอ้างอิง|แหล่งข้อมูลอ้างอิง|อ้างอิงจาก) *==/g,'$1อ้างอิง =='); text = text.replace(/(== ?) ?(ดูเพิ่มเติม|ดูเพื่มเติม|ดูเพิ่มที่|อ่านเพิ่ม|อ่านเพิ่มเติม|หัวข้อที่เกี่ยวข้อง|หัวข้ออื่นที่เกี่ยวข้อง) *==/g,'$1ดูเพิ่ม =='); text = text.replace(/(== ?) ?(เว็บไซต์|เว็บไซต์ภายนอก|เว็บไซต์์์อื่น|เว็บไซต์์์์์์อื่น|เว็บไซต์อื่น|เว็บไซต์ที่เกี่ยวข้อง|ข้อมูลภายนอก|โยงภายนอก|เว็บลิงก์ภายนอก|ลิงก์ภายนอก|ลิงค์ภายนอก|ดูลิงก์ภายนอก|แหล่งข้อมูลภายนอก|แหล่งข้อมูลเพิ่มเติม|แหล่งข้อข้อมูลอื่น) *==/g,"$1แหล่งข้อมูลอื่น =="); text = text.replace(/(== ?) ?(Link\s?ภายนอก|link\s?ภายนอก|เว็บแหล่งข้อมูลอื่น) *==/g,"$1แหล่งข้อมูลอื่น =="); text = text.replace(/(== ?) ?(ประวัติความเป็นมา|ประวัติส่วนตัว|ความเป็นมา|ชีวประวัติ) *==/g,"$1ประวัติ =="); //InterLink Check if(wgCanonicalNamespace.length == 0 && text.indexOf("{{ลิงก์ไปภาษาอื่น}}") == -1 && text.indexOf("[[:en:") != -1) { text = "{{ลิงก์ไปภาษาอื่น}}\n" + text; if(document.editform.wpSummary.value.length == 0) { document.editform.wpSummary.value = "แจ้งลิงก์ข้ามภาษา"; } else { document.editform.wpSummary.value += " +แจ้งลิงก์ข้ามภาษา"; } } document.editform.wpTextbox1.value = text; if(isSpeedy == 1) { if(document.editform.wpSummary.value.length == 0) { document.editform.wpSummary.value = "เก็บกวาดทันใจด้วย[[ผู้ใช้:Jutiphan/Scripts|สคริปต์จัดให้]]"; document.editform.wpMinoredit.checked = true; } else { document.editform.wpSummary.value += " +เก็บกวาดทันใจด้วย[[ผู้ใช้:Jutiphan/Scripts|สคริปต์จัดให้]]"; } } else { if(document.editform.wpSummary.value.indexOf("เก็บกวาดด้วย[[ผู้ใช้:Jutiphan/Scripts|สคริปต์จัดให้]]") == -1) { if(document.editform.wpSummary.value.length == 0) { document.editform.wpSummary.value = "จัดรูปแบบ +เก็บกวาดด้วย[[ผู้ใช้:Jutiphan/Scripts|สคริปต์จัดให้]]"; } else { var eIndex = document.editform.wpSummary.value.lastIndexOf("ด้วย[[ผู้ใช้:Jutiphan/Scripts|สคริปต์จัดให้]]"); if(eIndex != -1) { var strTmp = document.editform.wpSummary.value; document.editform.wpSummary.value = strTmp.substring(0,eIndex) + " +เก็บกวาดด้วย[[ผู้ใช้:Jutiphan/Scripts|สคริปต์จัดให้]]"; } else { document.editform.wpSummary.value = document.editform.wpSummary.value + " +เก็บกวาดด้วย[[ผู้ใช้:Jutiphan/Scripts|สคริปต์จัดให้]]"; } } } } document.body.style.cursor = 'auto'; } // ========== เพิ่มปุ่มเก็บกวาดบน Toolbar ========== addOnloadHook( function() { var tooly = document.getElementById('toolbar'); if (tooly != null) { var cleanupButton = "<a href=\"javascript:doCleanupTag();\"><img src=\"http://upload.wikimedia.org/wikipedia/th/9/96/Button_cleanup.png\" alt=\"เก็บกวาด\"></a>"; tooly.innerHTML = tooly.innerHTML + cleanupButton; } }); // ========== เก็บกวาดทันใจ(แสดงที่หน้าบทความ) ========== addOnloadHook(function() { //Add tab if it is an article if(wgIsArticle) { addTab("javascript:doSpeedyCleanup()", "เก็บกวาด", "ca-scleanup", "เก็บกวาดทันใจ", ""); } if (document.title.indexOf("แก้ไข") != -1) { if (document.URL.lastIndexOf("&fakeaction=speedycleanup") == -1) return; if (wgArticleId == 0) return; doCleanupTag(1); document.editform.submit(); return; } }); function doSpeedyCleanup() { //edit page var title = document.title.substr(0, document.title.lastIndexOf(' - วิกิพีเดีย')); location.assign("/w/index.php?title=" + title + "&action=edit&fakeaction=speedycleanup"); } /* </nowiki></pre> */