Jump to content

User:Misza13/modern.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.
// <nowiki>
importScript('User:AzaToth/morebits.js');

importScript('User:Mr.Z-man/closeAFD.js');

if (mw.config.get('wgPageName') == 'Special:Watchlist') {
  importScript('User:Misza13/watchlistSorter.js');
  importStylesheet('User:Misza13/watchlistSorter.css');
}

if (mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') {
  importScript('User:Misza13/votingToolbar.js');
}

//////////TOOLBOX LINKS
function make_link(url, text) {
  newA = document.createElement('a');
  newA.href = url;
  newA.appendChild(document.createTextNode(text));
  return newA;
}

$(function(){
 // get page title
 var pagetitleRe=/[^:]*:\/\/en\.wikipedia\.org\/(wiki\/|w\/index\.php(?:\?.*&|\?)title=)([^&?#]*)/;
 ptitle = pagetitleRe.exec(decodeURI(location.href))[2].split('_').join(' ');
 user_logs_url1 = "";
 misza_counter = "";
 
 toolbox = document.getElementById('p-tb').getElementsByTagName('ul')[0];
 
 mw.util.addPortletLink("p-tb", '/wiki/Special:Log', 'All logs');
 mw.util.addPortletLink("p-tb", '/wiki/Special:Ipblocklist', 'Block list');
 
 // if this is a user, show the logs for the user rather than the page
 if( mw.config.get('wgNamespaceNumber') == 2 || mw.config.get('wgNamespaceNumber') == 3 ) {
   user = mw.config.get('wgTitle').split('/')[0].replace(" ","_");

   user_logs_url1 = "http://en.wikipedia.org/w/index.php?title=Special%3ALog&user=" + user;
   user_logs_url2 = "http://en.wikipedia.org/w/index.php?title=Special%3ALog&page=User:" + user;
   logLI = document.createElement('li');
   logLI.appendChild(make_link('http://en.wikipedia.org/wiki/User:'+user,'User'));
   logLI.appendChild(document.createTextNode(' ('));
   logLI.appendChild(make_link(user_logs_url1,'logs'));
   logLI.appendChild(document.createTextNode(' • '));
   logLI.appendChild(make_link(user_logs_url2,'logs'));
   logLI.appendChild(document.createTextNode(')'));
   toolbox.appendChild(logLI);

   //misza_counter = "http://tools.wikimedia.de/~misza13/cgi-bin/count.py?user=" + user + "&project=enwiki_p";
   //mw.util.addPortletLink("p-tb", misza_counter, "Misza counter", "pt-misza-counter");
 }

 mw.util.addPortletLink("p-tb", '/w/index.php?title=Special:Log&page=' + ptitle, 'Page logs');
 mw.util.addPortletLink("p-tb", '/wiki/User:Misza13/Scripts', 'Scripts');
 mw.util.addPortletLink("p-tb", '/wiki/User:MiszaBot', 'MiszaBot');
 //mw.util.addPortletLink("p-tb", '/wiki/User:MiszaBot_I', 'MiszaBot I');
 //mw.util.addPortletLink("p-tb", '/wiki/User:MiszaBot_II', 'MiszaBot II');
 //mw.util.addPortletLink("p-tb", '/wiki/User:MiszaBot_III', 'MiszaBot III');
 //mw.util.addPortletLink("p-tb", '/wiki/User:WdefconBot', 'WdefconBot');
 mw.util.addPortletLink("p-tb", '/wiki/User:Wikinews_Importer_Bot', 'Wikinews Importer Bot');
 mw.util.addPortletLink("p-tb", 'http://pl.wikipedia.org/wiki/Wikipedysta:Misza13', 'pl:Misza13');
});

//////// QuickBlocks
/*function QuickBlock (expiry,reason,ao,ab,autob,emailb) {
  blockForm = document.getElementById('blockip');
  inputs = blockForm.getElementsByTagName('input');
  for (i=0; i<inputs.length; i++) {
    if (inputs[i].name == 'wpBlockOther') {
      inputs[i].value = expiry;
      continue;
    }
    if (inputs[i].name == 'wpBlockReason') {
      inputs[i].value = reason;
      continue;
    }
    if (inputs[i].name == 'wpAnonOnly') {
      if (ao==1) {
        inputs[i].checked = 'checked';
      }
      continue;
    }
    if (inputs[i].name == 'wpEnableAutoblock') {
      if (autob==0) {
        inputs[i].checked=false;
      }
      continue;
    }
    if (inputs[i].name == 'wpCreateAccount') {
      if (ab==0) {
        inputs[i].checked=false;
      }
      continue;
    }
    if (inputs[i].name == 'wpEmailBan') {
      if (emailb==1) {
        inputs[i].checked=true;
      }
      continue;
    }
  }
  blockForm.submit();
}*/
 
/*addOnloadHook(function(){
  if (mw.config.get('wgPageName') != "Special:BlockIP") return;
  var user = document.getElementById('mw-bi-target').value;
  var isAOL = AOLNetworks.some( function( net ) { return isInNetwork( user, net ) } );
  mw.util.addPortletLink('p-cactions','javascript:('+QuickBlock+')("indefinite","{{UsernameBlocked}}",0,0,0,0)','user...','p-block-user')
  mw.util.addPortletLink('p-cactions','javascript:('+QuickBlock+')("indefinite","{{UsernameHardBlocked}}",1,1,1,0)','(AB) user...','p-block-b-user')
  mw.util.addPortletLink('p-cactions','javascript:('+QuickBlock+')("indefinite","Vandalism account",0,0,1,0)','vandalism','p-block-vandalism')
  mw.util.addPortletLink('p-cactions','javascript:('+QuickBlock+')("indefinite","[[Wikipedia:Vandalism|Vandalism]]-only account",0,1,1,1)','grawp','p-block-grawp')
  mw.util.addPortletLink('p-cactions','javascript:('+QuickBlock+')("indefinite","{{blocked proxy}}",0,0,0,0)','open proxy','p-block-proxy')
  if (isAOL) {
    mw.util.addPortletLink('p-cactions','javascript:('+QuickBlock+')("1 hour","{{AOLblock}}",1,0,0,0)','AOL (1h)','p-block-AOL-1h')
  } else {
    mw.util.addPortletLink('p-cactions','javascript:('+QuickBlock+')("12 hours","[[Wikipedia:Vandalism|Vandalism]]",1,0,1,0)','vandalism (12h)','p-block-12h')
    mw.util.addPortletLink('p-cactions','javascript:('+QuickBlock+')("31 hours","[[Wikipedia:Vandalism|Vandalism]]",1,0,1,0)','vandalism (31h)','p-block-31h')
    mw.util.addPortletLink('p-cactions','javascript:('+QuickBlock+')("3 hours","{{schoolblock}}",1,1,0,0)','school (3h)','p-block-school')
    mw.util.addPortletLink('p-cactions','javascript:('+QuickBlock+')("3 hours","{{anonblock}}",1,0,1,0)','vandalism (3h)','p-block-3h')
    mw.util.addPortletLink('p-cactions','javascript:('+QuickBlock+')("1 week","Repeated vandalism",1,0,1,0)','One week','p-block-week');
    mw.util.addPortletLink('p-cactions','javascript:('+QuickBlock+')("1 month","Chronic vandalism",1,0,1,0)','One month','p-block-month');
  }
});*/

//////// BIG BLOCK BUTTON
/*addOnloadHook(function () {
  blockip = document.getElementById('t-blockip');
  if (blockip) {
    blockButton = document.createElement('a');
    blockButton.href = blockip.firstChild.href;
    blockButton.style.color = "red";
    blockButton.appendChild(document.createTextNode('BLOCK'));
    firstHeading = document.getElementById('firstHeading');
    firstHeading.appendChild(document.createTextNode(' ('));
    firstHeading.appendChild(blockButton);
    firstHeading.appendChild(document.createTextNode(')'));
  }
});*/

/////Test of JS edit tools
//importScript("User:Ilmari Karonen/edittoolstest.js");
//window.testJsEdittools = true;
// </nowiki>