ผู้ใช้:Bebiezaza/dev/iScript/cleanup.js

จากวิกิพีเดีย สารานุกรมเสรี

หมายเหตุ: หลังเผยแพร่ คุณอาจต้องล้างแคชเว็บเบราว์เซอร์ของคุณเพื่อดูการเปลี่ยนแปลง

  • ไฟร์ฟอกซ์ / ซาฟารี: กด Shift ค้างขณะคลิก Reload หรือกด Ctrl-F5 หรือ Ctrl-R (⌘-R บนแมค)
  • กูเกิล โครม: กด Ctrl-Shift-R (⌘-Shift-R บนแมค)
  • อินเทอร์เน็ตเอกซ์พลอเรอร์ และ Edge: กด Ctrl ค้างขณะคลิก Refresh หรือกด Ctrl-F5
  • โอเปร่า: กด Ctrl-F5
// ==============================================================
// สคริปต์จัดให้: cleanup module
//
// Copyright (C) 2006-2021, Jutiphan Mongkolsuthree
// Certain functions are copyrighted by their
// respective copyright holders
//
// Some operations are originated from
// http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Formatter
//
// Created: 08/03/2008
// Replaced: none
// ==============================================================
/* <pre><nowiki> */
// ========== จัดรูปแบบ+เก็บกวาด ==========
// สคริปต์นี้ เปลี่ยนคำสั่งเก่า เช่น Category, Image, และข้อความเก่า
function doCleanupTag(isSpeedy) {
    document.body.style.cursor = 'wait';
    var text = document.editform.wpTextbox1.value;

    if (text.indexOf("nocleanup") >= 0) {
        alert("ขออภัย หน้าดังกล่าวนั้นไม่ต้องการเก็บกวาด เนื่องจากว่าการเก็บกวาด ทำให้การแสดงตัวอย่างความสามารถเก็บกวาดในหน้านี้มีปัญหาได้");
        return;
    }

    //Format
    //text = text.replace(/<br>|<br\/>/gi, "<br />");                                   //<br/> -> <br />
    text = text.replace(/([^\[]|^)^(?!CDATA)\[([^\[^\]]*?)\]\]/gm, "$1[[$2]]");                   //[ลิงก์ใน]] -> [[ลิงก์ใน]]
    //Depreciated because of certain conditions would cause this to fail
    //Case study: [[ภาพ:Cube root.png|right|thumb|288px|กราฟของสมการ <math>y = \sqrt[3]{x}</math>]] 
    //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(/\n(={1,5}) ?''' ?(.*) ?''' ?(={1,5})/gm, "\n$1 $2 $3");       //== '''หัวข้อ''' == -> == หัวข้อ ==
    text = text.replace(/^= ?([^=].*?) ?=/gm, "== $1 ==");                               //= หัวข้อ =  -> == หัวข้อ ==
    text = text.replace(/^(={1,5}) *(.*?) ?(={1,5}) *$/gm, "$1 $2 $3");              //==หัวข้อ== -> == หัวข้อ ==
    //text = text.replace(/&nbsp;/g, " ");
    text = text.replace(/&prime;/g, "'");
    text = text.replace(/&amp;/g, "&");
    text = text.replace(/&minus;/g, "−");
    text = text.replace(/&times;/g, "×");
    text = text.replace(/&mdash;/g, "—");
    text = text.replace(/&ndash;/g, "-");

    //[[หมวดหมู่: xxx]] -> [[หมวดหมู่:xxx]]
    text = text.replace(/\[\[หมวดหมู่:\s(.*?)\]\]/g, "[[หมวดหมู่:$1]]");

    //{{แม่แบบ:xxx}} -> {{xxx}}
    text = text.replace(/{{แม่แบบ:(.*?)}}/g, "{{$1}}");

    //Fix spacing, </xxx > -> </xxx>
    text = text.replace(/<\/(.*?) ?>/g, "</$1>");

    //Fix spacing between char and paren
    //Add exception for ps: interlanguage. Example:ps:ماينامار(برما)
    var re = /\[\[ps:(.*?)\]\]/ig;
    var matches = text.match(re);
    text = text.replace(/(.(?!( f\()).[^\s\[\]\(\_\#\/\{\"\f])\(/g, "$1$2 (");       //Ignore f(x) case from f (x)
    text = text.replace(/(.*?)\)([^\s\]\)\|\.\_\#\/\}\"\,\<\"])/g, "$1) $2");
    text = text.replace(/(.*?)\]\]\(/g, "$1]] (");                //Allow spacing for link scenario such as [[Link]](Hello World!)

    if(matches) {
        text = text.replace(/\[\[ps:.*?\]\]/ig, matches[0]);
    }
    //Fix spacing between yamok and char
    //text = text.replace(/)

    //Fix lang icons: Move from front to back
    //Depreciated because now the ref links are used inside ref tags.
    //Case Study: //th.wikipedia.org/w/index.php?title=%E0%B9%80%E0%B8%AB%E0%B8%95%E0%B8%B8%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%93%E0%B9%8C%E0%B9%81%E0%B8%9C%E0%B9%88%E0%B8%99%E0%B8%94%E0%B8%B4%E0%B8%99%E0%B9%84%E0%B8%AB%E0%B8%A7%E0%B9%83%E0%B8%99%E0%B8%A1%E0%B8%93%E0%B8%91%E0%B8%A5%E0%B9%80%E0%B8%AA%E0%B8%89%E0%B8%A7%E0%B8%99_%E0%B8%9E.%E0%B8%A8._2551&diff=1161797&oldid=1152067
    //text = text.replace(/\* ?({{.*? icon}}) ?(.*?)\r?\n/g, "* $2 $1\n");                            //แก้ * {{...}} [...] -> * [...] {{...}}
    text = text.replace(/<ref(.*?)> ?({{.*? icon}}) ?(.*?) ?<\/ref>/g, "<ref$1>$3 $2</ref>");//แก้ <ref...> {{...}} [...] </ref> -> <ref...>[...] {{...}}</ref>

    //Fix Template Parameters Layout: Move | from back to front (using Top to Bottom approach)
    text = text.replace(/ *\|(?!-) *\r?\n *([^=\*<|{}]*?) ?=(?!=) *([^\|={}]*?)/gm, "\n| $1 = $2");      //รวมแก้สองอย่างโดยการตรวจย้ายบนไปล่างแทน
    //text = text.replace(/({{.*)(?!})\| *\r/g,"$1");                                   //แก้ {{... | -> {{...
    //text = text.replace(/(\n) *([^|{}]*?) ?= *([^|{}]*?)\| *\r/g,"$1| $2 = $3");      //แก้ ... | -> | ...

    //TODO: Need comments for code below for maintenance reasons: Hard to debug
    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 in betweens
    text = text.replace(/\r?\n *\|(?!-) *([^=\|\?'"{}]*?) ?= *([^=]*?) */g, "\n| $1 = $2");

    //Fix Template: Remove extra | if exist at the end
    text = text.replace(/\n *\|(?!-) *([^=\|'"{}]*?)=([^=\|]*?) ?\r?\n?\| ?\r?\n?\}\}(?!\})/g, "\n| $1 = $2\n}}"); //| abc = 123 | }} -> | abc = 123 }}

    //Fix Year Formatting
    text = text.replace(/(พ\. ?ศ\. ?|พศ\. ?)(\d{1,4})/g, "พ.ศ. $2");
    text = text.replace(/(ค\. ?ศ\. ?|คศ\. ?)(\d{1,4})/g, "ค.ศ. $2");

    //Fix double Thai vowels
    //# สระหน้า           เ|แ|โ|ใ|ไ
    //# สระหลัง           ะ|า|ๅ
    //# อำ คือ             ำ
    //# สระบน             ั|ิ|ี|ึ|ื|ํ
    //# สระล่าง            ุ|ู|ฺ
    //# ไม้ไต่คู้            ็
    //# วรรณยุกต์        ่|้|๊|๋
    //# ทัณฑฆาต        ์
    //# ไปยาลน้อย      ฯ
    //# ไม้ยมก            ๆ
    //text = text.replace(/(แ|โ|ใ|ไ|ะ|า|ๅ|ำ|ั|ิ|ี|ึ|ื|ํ|ุ|ู|ฺ|็|่|้|๊|๋|์){2,}/g, "$1") //remove dup

    text = text.replace(/ํา/g, "ำ"); //Nikhahit (nikkhahit) + Sara Aa -> Saram Am
    text = text.replace(/เเ/g, "แ"); //Sara E + Sara E -> Sara Ae
    text = text.replace(/(เ|แ|โ|ใ|ไ)(ะ|า|ๅ|ำ|ั|ิ|ี|ึ|ื|ํ|ุ|ู|ฺ|็|่|้|๊|๋|์)/g, "$1"); //สระหน้า
    text = text.replace(/(ะ|า|ๅ)(ำ|ั|ิ|ี|ึ|ื|ํ|ุ|ู|ฺ|็|่|้|๊|๋|์)/g, "$1");                //สระหลัง
    text = text.replace(/(ำ)(ำ|ั|ิ|ี|ึ|ื|ํ|ุ|ู|ฺ|็|่|้|๊|๋|์)/g, "$1");                    //สระอำ
    text = text.replace(/(ั|ิ|ี|ึ|ื|ํ)( ะ|า|ๅ|ำ|ั|ิ|ี|ึ|ื|ํ|ุ|ู|ฺ|็)/g, "$1");           //สระบน
    text = text.replace(/(ุ|ู|ฺ)( ะ|า|ๅ|ำ|ั|ิ|ี|ึ|ื|ํ|ุ|ู|ฺ|็)/g, "$1");                     //สระล่าง
    text = text.replace(/(็)( ะ|า|ๅ|ำ|ั|ิ|ี|ึ|ื|ํ|ุ|ู|ฺ|็)/g, "$1");                            //ไม้ไต่คู้
    text = text.replace(/(่|้|๊|๋)(ั|ิ|ี|ึ|ื|ํ|ุ|ู|ฺ|็|่|้|๊|๋|์)/g, "$1");               //วรรณยุกต์

    text = text.replace(/\u0E48\u0E48/g, "\u0E48"); //Mai Ek
    text = text.replace(/\u0E49\u0E49/g, "\u0E49"); //Mai Tho
    text = text.replace(/\u0E4A\u0E4A/g, "\u0E4A"); //Mai Tri
    text = text.replace(/\u0E4B\u0E4B/g, "\u0E4B"); //Mai Chattawa
    text = text.replace(/์์/g, "์"); //ทัณฑฆาต

    //Spellings
    if (text.indexOf("nofixbot") == -1) {
        var matches = /\n\{\{ชื่อนิยมอื่น\|(.*?)\}\}/.exec(text);
        
        text = text.replace(/ไบท์(?!\]\])/g, "ไบต์"); //Ordering is intended
    
        text = text.replace(/เยอรมันนี/g, "เยอรมนี");
        text = text.replace(/\sกฏ/g, " กฎ");
        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, "คริสต์$1");
        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(/ทะเลสาป(?!สีเลือด)/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, "บันเทิง");       //See: ประสิทธิ์ ศิริบรรเทิง and กรรณิการ์ บรรเทิงจิตร
        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(/มิวสิค(?!\u0E31)/g, "มิวสิก");
        text = text.replace(/ไมโครซอฟต์/g, "ไมโครซอฟท์");
        text = text.replace(/รถยนตร์/g, "รถยนต์");
        text = text.replace(/ร็อค(?!แม)/g, "ร็อก"); //ignore ร็อคแมน
        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(/สวดมน(?!\u0E21|\u0E15)|สวดมนตร์/g, "สวดมนต์");
        text = text.replace(/สวรรณคต/g, "สวรรคต");
        text = text.replace(/สังเกตุ/g, "สังเกต");
        text = text.replace(/อโดบี/g, "อะโดบี");
        text = text.replace(/อนิเม(?!\u0E30|ช|ท|ต)|อานิเมะ|อะนิเมะ/g, "อนิเมะ");
        //text = text.replace(/อนิเม(?!ช|ท|ต)|อานิเมะ|อะนิเม(?!\u0E30|\u0E47|ช|ท|ต|เ|แ)/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(/เอล์ฟ/, "เอลฟ์");
        text = text.replace(/เอาท์พุต|เอาท์พุท/g, "เอาต์พุต");
        text = text.replace(/แอปพลิเคชั่น|แอพพลิเคชั่น|แอพพลิเคชัน|แอพพลิคเคชัน/g, "แอปพลิเคชัน");
    
        //Exceptions cases handling
        text = text.replace(/คริสต์มาส วิไลโรจน์/g, "คริสมาส วิไลโรจน์");
        text = text.replace(/สมาคมเนชั่นแนล จีโอกราฟิก/g, "สมาคมเนชั่นแนล จีโอกราฟฟิก");
        text = text.replace(/(อีเอ็มไอ|เบเกอรี่)มิวสิก/g, "$1มิวสิค");
        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(/\[\[template:/gi, 'แม่แบบ:');
        text = text.replace(/(>|\n|\[|^)(image|file):/gi, '$1ไฟล์:');
        text = text.replace(/(>|\n|\[|^)ภาพ:/gi, "$1ไฟล์:");
  
        if(matches != null) {
            text = text.replace(/\n{{ชื่อนิยมอื่น.*/, matches[0]);
        }
    }
  
  
    if (mw.config.get('wgNamespaceNumber') == 0 && mw.config.get('wgPageName').indexOf("วิกิพีเดีย:") != 0) {
        if(iScriptConfig.Edition != Editions.Uncyclopedia) {
            //Remove signatures on article pages if not uncyclopedia
            text = text.replace(/-{0,2} ?\[\[ผู้ใช้:.*/g, "");
        }
    
        //Remove begin line spaces to help newcomers
        text = text.replace(/== ?\n *(.*\n)/gi, "==\n$1");
  
    }
  
    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ประวัติ ==");
  
    //Basic Replace [[wgPageName]] to '''wgPageName'''
    //TODO: Handle possible param
    var titleLink = new RegExp("\\[\\[" + mw.config.get('wgPageName') + "\\]\\]", "g");
    text = text.replace(titleLink, "'''" + mw.config.get('wgPageName') + "'''");
  
    //InterLink Check
    var textWithoutComments = text.replace(/<!--(.*\n)*.*-->/ig, "");
    if (mw.config.get('wgNamespaceNumber') == 0 && mw.config.get('wgPageName').indexOf("วิกิพีเดีย:") != 0 && text.indexOf("{{ลิงก์ไปภาษาอื่น}}") == -1 && (textWithoutComments.indexOf("[[:en:") != -1 || textWithoutComments.indexOf("[//en.wikipedia.org/w") != -1)) {
        text = "{{ลิงก์ไปภาษาอื่น}}\n" + text;
        if (document.editform.wpSummary.value.length == 0) {
            document.editform.wpSummary.value = "แจ้งลิงก์ข้ามภาษา";
        } else {
            document.editform.wpSummary.value += " +แจ้งลิงก์ข้ามภาษา";
        }
    }
  
    //Category & wikiLink Check only for article, wikipedia, category and ignore check if editing section of article
    if ((mw.config.get('wgNamespaceNumber') == 0 || mw.config.get('wgNamespaceNumber') == 4 || mw.config.get('wgNamespaceNumber') == 14) && document.URL.indexOf("&section=") == -1 && text.indexOf("#REDIRECT") == -1 && text.indexOf("# REDIRECT") == -1 && text.indexOf("{{เก็บกวาด}}") == -1 && text.indexOf("{{แก้กำกวม") == -1) {
        var i = text.indexOf("[[หมวดหมู่:");
        if (text.indexOf("{{ต้องการหมวดหมู่}}") == -1 && i < 0) {
            text = "{{ต้องการหมวดหมู่}}\n" + text;
            if (document.editform.wpSummary.value.length == 0) {
            document.editform.wpSummary.value = "แจ้งต้องการหมวดหมู่";
            } else {
            document.editform.wpSummary.value += " +ต้องการหมวดหมู่";
            }
        } else if (i > 0) {
            text = text.replace(/{{ต้องการหมวดหมู่}}\n?/g, "");
        }
  
        //WikiLink check
        var containsWiki = (/\[\[[^:]*?\]\]/.test(text));
        if (text.indexOf("{{ต้องการวิกิลิงก์") < 0 && mw.config.get('wgNamespaceNumber') != 14 && !containsWiki) {
            text = "{{ต้องการวิกิลิงก์}}\n" + text;
            if (document.editform.wpSummary.value.length == 0) {
            document.editform.wpSummary.value = "แจ้งต้องการวิกิลิงก์";
            } else {
            document.editform.wpSummary.value += " +ต้องการวิกิลิงก์";
            }
        } else if (containsWiki) {
            text = text.replace(/{{ต้องการวิกิลิงก์}}\n?/g, "");
        }
    }
  
    if (mw.config.get('wgNamespaceNumber') == 0) {
        //Move stub below categories
        text = text.replace(/\r?\n{{โครง(?!-?ส่วน|การพี่น้อง)(.*?)}} ?(((\r?\n.*?)*?\r?\n\[\[หมวดหมู่:.*?\]\])*)/g, "$2\n{{โครง$1}}");
    }
  
    document.editform.wpTextbox1.value = text;
    if (isSpeedy == 1) {
        if (document.editform.wpSummary.value.length == 0) {
            document.editform.wpSummary.value = "เก็บกวาดทันใจ" + iScriptConfig.Tagline;
            document.editform.wpMinoredit.checked = true;
        } else {
            document.editform.wpSummary.value += " +เก็บกวาดทันใจ" + iScriptConfig.Tagline;
        }
        } else {
        if (document.editform.wpSummary.value.indexOf("เก็บกวาด" + iScriptConfig.Tagline) == -1) {
            if (document.editform.wpSummary.value.length == 0) {
            document.editform.wpSummary.value = "จัดรูปแบบ +เก็บกวาด" + iScriptConfig.Tagline;
            } else {
            var eIndex = document.editform.wpSummary.value.lastIndexOf(iScriptConfig.Tagline);
            if (eIndex != -1) {
                var strTmp = document.editform.wpSummary.value;
                document.editform.wpSummary.value = strTmp.substring(0, eIndex) + " +เก็บกวาด" + iScriptConfig.Tagline;
            } else {
                document.editform.wpSummary.value = document.editform.wpSummary.value + " +เก็บกวาด" + iScriptConfig.Tagline;
            }
            }
        }
    }
    document.body.style.cursor = 'auto';
    document.editform.wpTextbox1.focus();
}