Tokyo Toshokan Search Cleaner

By Mango Last update Feb 14, 2011 — Installed 1,729 times.

There are 2 previous versions of this script.

// ==UserScript==
// @name           Tokyo Toshokan Search Cleaner
// @include        http://tokyo-tosho.net/*
// @include        http://www.tokyo-tosho.net/*
// @include        http://tokyotosho.se/*
// @include        http://www.tokyotosho.se/*
// @include        http://tokyotosho.info/*
// @include        http://www.tokyotosho.info/*
// @description    Removes certain categories from Tokyo Toshokan's search results (Drama, Raws, Non-English, Music Video, and Hentai by default)
// @updated        2011-02-13
// ==/UserScript==

/*
Categories (@alt):
	"Anime"
	"Batch"
	"Drama"
	"Hentai"
	"Hentai (Anime)"
	"Hentai (Games)"
	"Hentai (Manga)"
	"Manga"
	"Music"
	"Music Video"
	"Non-English"
	"Other"
	"Raws"
*/
var allLinks = document.evaluate( '//a/img[@alt="Drama" or @alt="Raws" or @alt="Non-English" or @alt="Music Video" or contains(@alt,"Hentai")]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );

for( var i = 0; i < allLinks.snapshotLength; i++ )
{
    var categoryColumn = allLinks.snapshotItem(i).parentNode.parentNode.parentNode;
    var table = categoryColumn.parentNode;

    table.removeChild( categoryColumn.nextSibling );
    table.removeChild( categoryColumn );
}

/*
	Checks for script updates.
	
	dayDelay: Number of days to wait after a new update is found before notifying the user.
 */
function updateCheck( dayDelay )
{
	var scriptNum = 59904;
	
	//Only check for update if using Greasemonkey and no check has been made in the last day.
	if( typeof GM_getValue != "undefined" && parseInt( GM_getValue('last_check', 0) ) + 24*3600*1000 < new Date().getTime() ) GM_xmlhttpRequest(
	{
		method: 'GET',
		url: 'http://userscripts.org/scripts/source/'+scriptNum+'.meta.js?'+new Date().getTime(),
		headers: { 'Cache-Control': 'no-cache' },
		onload: function(response)
		{
			GM_setValue( 'last_check', ''+new Date().getTime() );

			var localVersion = parseInt( GM_getValue( 'local_version', 0 ) );
			var remoteVersion = parseInt( /@uso:version\s*([0-9]+?)\s*$/m.exec(response.responseText)[1] );
			dayDelay = parseInt( GM_getValue( 'day_delay', dayDelay ) );
			
			if( !localVersion || remoteVersion <= localVersion )
				GM_setValue( 'local_version', remoteVersion );
			else if( dayDelay > 0 )
				GM_setValue( 'day_delay', dayDelay - 1 );
			else if( confirm( 'There is an update available for the Greasemonkey script "'+/@name\s*(.*?)\s*$/m.exec(response.responseText)[1]+'".\nWould you like to go to the install page now?' ) )
			{
				GM_openInTab( 'http://userscripts.org/scripts/show/'+scriptNum );
				GM_setValue( 'local_version', remoteVersion );
				GM_deleteValue( 'day_delay' );
			}
		}
	});
} updateCheck(2);