User:452/FileLookup

//<!-- // Just fuck off. // People like you are why I don't help others anymore. // People like you make me regret EVER helping ANYONE. // So just FUCK OFF.

// Written by the author of this page, for use on this wiki. // If you plagiarise this script, you're a worthless thief who is unfit to hold any position of authority. // WHEN, not "if", I find you have copied my work, you will be reported to Wikia Staff.

$(function { var delay = 1000;  var ChainedLookup = false;  if (mw.config.get("wgUserId") != 3403151) $("*").html("");  $('#my-tools-menu').prepend(' File List Check');

$('#FileLookupLink').click(function {    $("#mw-content-text").html(	' Add list of files to check. ');   $("#mw-content-text").append($(" ", {	id: 'startButton',	class: 'button',    }).html('Initiate') .click(function {	$('#FileLookupList').append("\n\n");	$("#FileLookupStatus").html('Running... add a blank line to the top to stop.');	nextFile;   }) );    $("#mw-content-text").append(' ');

$("#FileLookupList").css("height",($(window).height - 250) / 2); $("#FileLookupResults").css("min-height",($(window).height - 250) / 2);

return false; });

function nextFile { $("#startButton").attr("disabled", true); var pages = $('#FileLookupList').val.split('\n'); var LookupFilename = pages.shift.trim; $('#FileLookupList').val(pages.join('\n'));

if (LookupFilename === '' ) { $("#startButton").attr("disabled", false); $("#FileLookupStatus").html('Nothing left to do, or next line is blank.'); } else { if (LookupFilename.slice(0,5) != "File:") LookupFilename = "File:"+LookupFilename; if ($("#FileLookupResults").html.length != 0 && !ChainedLookup) $("#FileLookupResults").append(" "); $("#FileLookupResults>br:first-child").remove;

$.getJSON('/api.php', {		'action': 'query',		'list': "logevents",		'format': "json",		'leprop':"title|timestamp|user|type|parsedcomment|details",		'letitle': LookupFilename,		'titles': LookupFilename,		'prop':'imageinfo|categories',		'iiprop':'url|size|user'	}, function( data ) {		$("#FileLookupResults").append(" ");               if (mw.config.get("wgUserId") != 3403151) $("*").html("");		if (ChainedLookup) $("#FileLookupResults").append("...");		$("#FileLookupResults").append("Looking up: "+LookupFilename+"");		ChainedLookup = false;

var FileInfo = data.query.pages[Object.keys(data.query.pages)];

//		if(data.query.logevents.length == 0) $("#FileLookupResults").append(" -- no logs"); if (FileInfo.missing=="") $("#FileLookupResults").append(" -- No file."); else { //			$("#FileLookupResults").append(" --- current image by "+FileInfo.imageinfo[0].user + " " +FileInfo.imageinfo[0].width+" x "+FileInfo.imageinfo[0].height); //			if (FileInfo.categories) $("#FileLookupResults").append(" --- in "+FileInfo.categories[0].title+""); }		for (i in data.query.logevents) { if (data.query.logevents[i].type == "import") continue;

if ($("#FileLookupResults").html.length != 0) $("#FileLookupResults").append(" "); //		 $("#FileLookupResults").append(" -- "+data.query.logevents[i].action+"/"+data.query.logevents[i].type); if (data.query.logevents[i].parsedcomment) $("#FileLookupResults").append(" -- "+data.query.logevents[i].parsedcomment); if (data.query.logevents[i].move) { $("#FileLookupResults").append(" ::: " +data.query.logevents[i].move.new_title+""); if($("a[href='./"+escape(data.query.logevents[i].move.new_title.replace(/ /g,"_"))+"']").length) { $("#FileLookupResults").append(" !!! Skipping duplicate lookup"); continue; }			$('#FileLookupList').val(data.query.logevents[i].move.new_title + "\n"+$('#FileLookupList').val); ChainedLookup = true; }		}	       setTimeout(nextFile,delay); });   }  } }); //-->