Jump to content

User:Super-Magician/QuickWarn.js

From Wikipedia, the free encyclopedia
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.
// Modified from Voice of All's non-admin RC patrol JavaScript

// <pre><nowiki>
// Quick warning definitions
function tnaddlilink(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);

  var txt = document.createTextNode(name);
  na.appendChild(txt);

  var li = document.createElement('li');
  li.appendChild(na);
  return li;
}

function testn(number)
{
  var IPnote = '';
  if (document.title.split(' - ')[0].split('.').length == 4)
  {IPnote = "''If this is an [[IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:Vandalism|unconstructive]] edits.'' ";}
  var varticle = '';
  if (location.href.indexOf('&vanarticle=') != -1)
  {varticle = unescape(location.href.split('&vanarticle=')[1].split('&')[0].replace(/(Image|Category):/i,':$1:'));}
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "=== Regarding edits made during [[{{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}]] [[{{subst:CURRENTYEAR}}]] ([[UTC]]) ===" + "\n" + "{{subst:" + "uw-test" + number + "|" + varticle + "|subst=subst:}} " + IPnote + "~" + "~" + "~" + "~";
  f.wpSummary.value = "Adding notice:" + " {{uw-test" + number + "}}";
}

function vandn(number)
{
  var IPnote = '';
  if (document.title.split(' - ')[0].split('.').length == 4)
  {IPnote = "''If this is an [[IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:Vandalism|unconstructive]] edits.'' ";}
  var varticle = '';
  if (location.href.indexOf('&vanarticle=') != -1)
  {varticle = unescape(location.href.split('&vanarticle=')[1].split('&')[0].replace(/(Image|Category):/i,':$1:'));}
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "=== Regarding edits made during [[{{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}]] [[{{subst:CURRENTYEAR}}]] ([[UTC]]) ===" + "\n" + "{{subst:" + "uw-vandalism" + number + "|" + varticle + "|subst=subst:}} " + IPnote + "~" + "~" + "~" + "~";
  f.wpSummary.value = "Adding notice:" + " {{uw-vandalism" + number + "}}";
}

function vandim()
{
  var IPnote = '';
  if (document.title.split(' - ')[0].split('.').length == 4)
  {IPnote = "''If this is an [[IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:Vandalism|unconstructive]] edits.'' ";}
  var varticle = '';
  if (location.href.indexOf('&vanarticle=') != -1)
  {varticle = unescape(location.href.split('&vanarticle=')[1].split('&')[0].replace(/(Image|Category):/i,':$1:'));}
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "=== Regarding edits made during [[{{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}]] [[{{subst:CURRENTYEAR}}]] ([[UTC]]) ===" + "\n" + "{{subst:" + "uw-vandalism4im" + "|" + varticle + "|subst=subst:}} " + IPnote + "~" + "~" + "~" + "~";
  f.wpSummary.value = "Adding notice: {{uw-vandalism4im}}";
}

function warningn()
{
  var IPnote = '';
  if (document.title.split(' - ')[0].split('.').length == 4)
  {IPnote = "''If this is an [[IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:Vandalism|unconstructive]] edits.'' ";}
  var varticle = '';
  if (location.href.indexOf('&vanarticle=') != -1)
  {varticle = unescape(location.href.split('&vanarticle=')[1].split('&')[0].replace(/(Image|Category):/i,':$1:'));}
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "=== Regarding edits made during [[{{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}]] [[{{subst:CURRENTYEAR}}]] ([[UTC]]) ===" + "\n" + "{{subst:" + "uw-bv" + "|" + varticle + "|subst=subst:}} " + IPnote + "~" + "~" + "~" + "~";
  f.wpSummary.value = "Adding notice: {{uw-bv}}";
}

// Quick warning tabs
$(add_testn_tabs);
function add_testn_tabs() 
{ 
var c1 = document.getElementById('column-one'); 
var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
if (document.title.indexOf("Editing User talk:") != -1)
    {
      tabs.appendChild(tnaddlilink('javascript:testn(1)',"t1"));
      tabs.appendChild(tnaddlilink('javascript:testn(2)',"t2"));
      tabs.appendChild(tnaddlilink('javascript:testn(3)',"t3"));
      tabs.appendChild(tnaddlilink('javascript:vandn(1)',"v1"));
      tabs.appendChild(tnaddlilink('javascript:vandn(2)',"v2"));
      tabs.appendChild(tnaddlilink('javascript:vandn(3)',"v3"));
      tabs.appendChild(tnaddlilink('javascript:vandn(4)',"w"));
      tabs.appendChild(tnaddlilink('javascript:vandim()',"im"));
      tabs.appendChild(tnaddlilink('javascript:warningn()',"bv"));
      if(document.getElementById('ca-nstab-user'))
      {
        document.getElementById('ca-nstab-user').firstChild.innerHTML = 'User';
      }
      if(document.getElementById('ca-talk'))
      {
        document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';
      }
      if(document.getElementById('ca-edit'))
      {
        document.getElementById('ca-edit').firstChild.innerHTML = 'Edit';
      }
      if(document.getElementById('ca-addsection'))
      {
        document.getElementById('ca-addsection').firstChild.innerHTML = '[+]';
      }
      if(document.getElementById('ca-history'))
      {
        document.getElementById('ca-history').firstChild.innerHTML = '[h]';
      }
      if(document.getElementById('ca-move'))
      {
      document.getElementById('ca-move').firstChild.innerHTML = '[m]';
      }
      if(document.getElementById('ca-delete'))
      {
        document.getElementById('ca-delete').firstChild.innerHTML = '[d]';
      }
      if(document.getElementById('ca-watch'))
      {
      document.getElementById('ca-watch').firstChild.innerHTML = '[w]';
      }
      if(document.getElementById('ca-unwatch'))
      {
      document.getElementById('ca-unwatch').firstChild.innerHTML = '[uw]';
      }
      if(document.getElementById('ca-protect'))
      {
        document.getElementById('ca-protect').firstChild.innerHTML = '[p]';
      }
      if(document.getElementById('ca-unprotect'))
      {
        document.getElementById('ca-unprotect').firstChild.innerHTML = '[up]';
      }
    }
}
// </nowiki></pre>