User:YuviPanda/lost.js

$( function {	if ( mw.config.get( 'wgNamespaceNumber' ) !== 0 ) {		return;	}	mw.loader.using( 'mediawiki.ui', function { var cats = $( "#mw-normal-catlinks ul a").map( function( i, a ) { return $(a).text }); var cat = cats[ Math.floor( Math.random * cats.length ) ]; $( "MEOW RANDOM!").click( function {			window.location.href = "/wiki/Special:RandomInCategory/" + cat;		}).appendTo( "#siteSub" );

var newLinks = $.map( $( "#mw-content-text a[href^='/wiki/']" ), function( node ) {			return $(node).attr('href');		}); newLinks = $.grep( newLinks, function( str ) {			return str.indexOf( ":" ) === -1;		});

var plainLink = newLinks[ Math.floor( Math.random * newLinks.length ) ];

$( "LINKY RANDOM!").click( function {			window.location.href = plainLink;			localStorage.randomOldLinks = JSON.stringify(newLinks);		}).appendTo( "#siteSub" );

var oldLinks = typeof localStorage.randomOldLinks === 'undefined' ? [] : JSON.parse( localStorage.randomOldLinks );

var intersectLinks = oldLinks.filter(function ( s ) { return newLinks.indexOf( s ) !== -1 } );

if ( intersectLinks.length ) { var intersectLink = intersectLinks[ Math.floor( Math.random * intersectLinks.length ) ]; $( "CLOSER RANDOM!").click( function {				window.location.href = intersectLink;				localStorage.randomOldLinks = JSON.stringify(newLinks);			}).appendTo( "#siteSub" ); }

} ); });