Jump to content

User:Anne drew/SetupAutoArchive.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Anne drew (talk | contribs) at 15:39, 30 September 2017 (change link in edit summary to point to docs). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
function addAutoArchive() {
  var talkHeader = document.editform.wpTextbox1.value.toLowerCase().indexOf("talk header") === -1
    && confirm("Also prepend standard {{talk header}} to page?") ? "yes" : "no";
  if((document.editform.wpTextbox1.value.indexOf("User:MiszaBot/config") === -1
    && document.editform.wpTextbox1.value.indexOf("User:ClueBot III/ArchiveThis") === -1)
    || confirm("It looks like this page already is being automatically archived. Are you sure you want to continue?")){
      document.editform.wpTextbox1.value = "{{subst:" + "Setup auto archiving|notice=yes|talk=" + talkHeader + "}}\n" + document.editform.wpTextbox1.value;
      document.editform.wpSummary.value = "Adding automatic archival using [[User:( ͡~ ͜ʖ ͡o)/SetupAutoArchive]]";
      document.getElementById('wpSave').click();
    }
}

jQuery( document ).ready( function( $ ) {
  if (mw.config.get('wgCanonicalNamespace').toLowerCase().indexOf("talk") > -1)
  if (document.editform) {
     mw.util.addPortletLink("p-cactions", "javascript:addAutoArchive()", "Setup Archive", "autoArchive", "Add auto archival", "");
  }
});