User:Frosty/uncyclopedia.js

From Uncyclopedia, the content-free encyclopedia
Jump to navigation Jump to search

Note: After saving, you have to bypass your browser's cache to see the changes.

  • Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button, or press Ctrl+F5.
  • Firefox: hold down the Shift key while clicking Reload; alternatively press Ctrl+F5 or Ctrl-Shift-R.
  • Opera, Konqueror and Safari users can just click the Reload button.
  • Chrome: press Ctrl+F5 or Shift+F5
// <pre><nowiki>
 
importScript('User:Lyrithya/rollback all.js');
importScript('User:Frosty/autobp.js');
importScript('User:Frosty/autotag.js');
importScript('User:Bizzeebeever/scripts/patrol.js')
 
 document.write('<script type="text/javascript" src="'
    + 'http://en.uncyclopedia.co/w/index.php?title=User:Frosty/autotalk.js'
    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
 document.write('<script type="text/javascript" src="'
    + 'http://en.uncyclopedia.co/w/index.php?title=User:Villahj_Ideeut/RC.js'
    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
// functions to run when the document loads
 
function Main() {
    addtoolbox();
}
 
 
// add to the toolbox
 
function addtoolbox() {
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, '/wiki/User:Frosty/List/Death', 'Shit for VFD', 't-articles');
    var ta = document.getElementById('p-navigation').getElementsByTagName('ul')[0];
    addlilink(ta, '/wiki/Uncyclopedia:Votes for deletion', 'Votes for Deletion', 'n-VFD');
    addlilink(ta, '/wiki/Uncyclopedia:QuickVFD', 'QuickVFD', 'n-qvfd');
    addlilink(ta, '/wiki/Uncyclopedia:Ban Patrol', 'Ban Patrol', 'n-bp');
}

/*
 * Ajax batch delete thingy, version [0.0.3] by Grunny
 * Based on: http://en.wikipedia.org/wiki/User:Splarka/ajaxbatchdelete.js
 * Converted to use jQuery
 */
$( function () {
	if( skin === 'monobook' ) {
		addPortletLink( 'p-tb', wgServer + wgScriptPath + '/index.php?title=Special:BlankPage&blankspecial=ajaxjqbd', 'Batch Delete');
	} else {
		$( '#my-tools-menu' ).prepend( '<li class="custom"><a href="' + wgServer + wgScriptPath + '/index.php?title=Special:BlankPage&blankspecial=ajaxjqbd" rel="nofollow">Batch Delete</a></li>' );
	}
} );
 
if( wgCanonicalSpecialPageName === 'Blankpage' && $.getUrlVar( 'blankspecial' ) === 'ajaxjqbd' ) {
	document.title = 'Ajax Batch Delete';
	$( createAjaxDeleteForm );
}
 
function createAjaxDeleteForm() {
	var	pageHeading = ( skin === 'oasis' ) ? ( $( '.AdminDashboardArticleHeader' ).length ? '.AdminDashboardArticleHeader > h1' : '.WikiaPageHeader > h1' ) : 'h1.firstHeading',
		bodyId = ( skin === 'oasis' ) ? '#WikiaArticle > p' : '#bodyContent > p',
		bdelFormHtml = '<form id="ajaxdeleteform" action="javascript:void(0);"><textarea style="height: 20em; width: 50%;" id="abd-textarea">'
			+ '</textarea><p><label for="abd-reason">Delete reason: </label><input type="text" style="width: 20em;" id="abd-reason" />'
			+ '</p><p><input type="button" id="abd-startbutton" value="start" onclick="ajaxDeleteStart()" /></p></form><pre id="abd-output"></pre>';
	$( pageHeading ).text( 'Ajax Batch Delete' );
	$( bodyId ).text('List of pages to delete:');
	$( bodyId ).after( bdelFormHtml );
}
 
function ajaxDeleteStart() {
	document.getElementById( 'abd-startbutton' ).setAttribute( 'disabled', 'disabled' );
	var	txt = document.getElementById( 'abd-textarea' ),
		deletes = txt.value.split( '\n' ),
		page = deletes[0],
		reason = document.getElementById( 'abd-reason' ).value,
		badchars = /(\#|\<|\>|\[|\]|\{|\}|\|)/;
	if( page === '' ) {
		$( '#abd-output' ).append( '* Done! Nothing left to do, or next line is blank.\n' );
		document.getElementById( 'abd-startbutton' ).removeAttribute( 'disabled');
	} else {
		if( badchars.test( page ) ) {
			$( '#abd-output' ).append( '! Illegal characters detected, skipping:' + page + '\n' );
			setTimeout( ajaxDeleteStart, 1000 );
		} else {
			$( '#abd-output' ).append( '> Attempting to delete [[' + page + ']]\n' );
			ajaxBatchDeleteAPage( page, reason );
		}
	}
	deletes = deletes.slice(1,deletes.length);
	txt.value = deletes.join( '\n' );
}
 
function ajaxBatchDeleteAPage( title, deleteReason ) {
	var url =  wgServer + wgScriptPath + '/api.php?action=query&prop=info&intoken=delete&titles=' + encodeURIComponent( title ) + '&format=json';
	$.getJSON( url, function( data ) {
		for ( var p in data.query.pages ) {
			break;
		}
		var	ET = data.query.pages[p].deletetoken,
			url = wgServer + wgScriptPath + '/api.php?action=delete&title=' + encodeURIComponent( title ) + '&reason=' + encodeURIComponent( deleteReason ) + '&format=json&token=' + encodeURIComponent( ET );
		$.post( url, function() {
			$( '#abd-output' ).append( '  > Deleted\n' );
			setTimeout( ajaxDeleteStart, 1000 );
		} );
	} );
}
 
// End Mass Delete
 
// Filter Special:Log Results - script by Splarka
 
if(wgPageName=='Special:Log') {
  addOnloadHook(function() {
    addPortletLink('p-cactions','javascript:speciallogRegexFilter()','Filter','p-logfilter','Regex filter the results on this page');
  });
}
 
var filter='Image\:';
function speciallogRegexFilter() {
  filter = prompt('Please enter a regular expression for this search',filter);
  if(filter==null) filter = '.*'
  var pattern = new RegExp(filter,'');
  var li=document.getElementById('bodyContent').getElementsByTagName('ul')[0].getElementsByTagName('li');
  var links=[];
  for(var i=0;i<li.length;i++) {
    litxt = getText(li[i]);
    (litxt.search(pattern)!=-1) ? li[i].style.display='block' : li[i].style.display='none'
  }
}
 
function getText(obj) {
  if (obj.nodeType == 3) return obj.nodeValue;
  var txt = new Array();
  var i=0;
  while(obj.childNodes[i]) {
    txt[txt.length] = getText(obj.childNodes[i]);
    i++;
  }
  return txt.join('');
} 
// </pre></nowiki>