Jump to content

Wikipedia:WikiProject User scripts/Scripts/CleanupTab.js

From Wikipedia, the free encyclopedia

This is the current revision of this page, as edited by Amorymeltzer (talk | contribs) at 13:20, 7 February 2021 (Amorymeltzer changed the content model of the page Wikipedia:WikiProject User scripts/Scripts/CleanupTab.js from "wikitext" to "JavaScript": Page is javascript). The present address (URL) is a permanent link to this version.

(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
// <pre>
// CleanupTab.js
//
// This script adds a "cleanup" tab to the top of article pages
// when in edit mode. It is disabled for the User namespace.

function doCleanup() {
  document.editform.wpTextbox1.value = '{' + '{' + 'Cleanup|date=' + '{' + '{' + 'subst:CURRENTMONTHNAME}} ' + '{' + '{' + 'subst:CURRENTYEAR}}}}\n\n' + document.editform.wpTextbox1.value;
  document.editform.wpSummary.value = 'Marked for cleanup.';
  document.editform.wpMinoredit.checked = true;
  document.editform.submit();
}

addOnloadHook(function() {
  if (mw.config.get('wgCanonicalNamespace') == "User" || mw.config.get('wgCanonicalNamespace') == "User_talk") {
     return;
  }
  if (document.editform) {
     addPortletLink("p-cactions", "javascript:doCleanup()", "cleanup", "ca-cleanup", "Mark for cleanup", "");
  }
});

// </pre>