ผู้ใช้:Jutiphan/Scripts/advert/monobook.js

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

หมายเหตุ: หลังจากบันทึกแล้ว, คุณต้องล้างแคชของเบราว์เซอร์เสียก่อน จึงจะเห็นการเปลี่ยนแปลง: Mozilla/Safari/Konqueror: กด Shift ค้าง แล้วกด Reload (หรือ Ctrl-Shift-R), IE: กด Ctrl-F5, Opera: กด F5

/* <pre><nowiki> */

// ========== แจ้งโฆษณา ==========
addOnloadHook(function() {
  //Add tab if it is an article and not a user page
  if(wgIsArticle && wgCanonicalNamespace.indexOf("User") == -1) {
    addTab("javascript:doAdvert()", "แจ้งโฆษณา", "ca-advert", "คำสั่งแจ้งโฆษณา", "");
  }

  if (document.title.indexOf("แก้ไข") != -1) {
    if (document.URL.lastIndexOf("&fakeaction=advert") == -1)
      return;
    if (wgArticleId == 0) {
      alert("บทความนี้ได้ถูกลบโดยผู้ดูแลระบบไปแล้ว");
      return;
    }

    document.editform.wpTextbox1.value = "{{โฆษณา}}\n\n" + document.editform.wpTextbox1.value;
    document.editform.wpSummary.value = "แจ้งโฆษณาด้วย[[ผู้ใช้:Jutiphan/Scripts|สคริปต์จัดให้]]";
    document.editform.submit();
    return;
  }
});
 
function doAdvert() {
  //edit page
  var title = document.title.substr(0, document.title.lastIndexOf(' - วิกิพีเดีย'));
  location.assign("/w/index.php?title=" + title + "&action=edit&fakeaction=advert");
}

/* </nowiki></pre> */