KoreanClass101 No Romanization

By Khakionion Last update Aug 2, 2009 — Installed 25 times. Daily Installs: 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

There are 3 previous versions of this script.

// ==UserScript==
// @name           KoreanClass101 - No Romaja
// @namespace      kc101romaja.khakionion.com
// @description    Gets rid of romanized Hangul text on KoreanClass101 vocabulary list pages.
// @include        http://www.koreanclass101.com/*/vocabulary_list
// ==/UserScript==

//support GreaseKit/Safari
var unsafeWindow = window;

//make the undesirables a global-level script object so we can remove/add the romanizations at will.
unsafeWindow.romanizationCount = 0;

//this function depends on the user script having found romanizations to toggle.
unsafeWindow.toggleRomaja = function() 
{
    for(i=0;i<unsafeWindow.romanizationCount;++i)
    {
	nextElem = document.getElementById("KC101NoRomaja"+i);
	nextElem.style.display=(nextElem.style.display=="none")?"":"none";
    }
}

//to start, find the first table of class 'Dictionary' in the page.
dictionaryTable = document.evaluate( "//table[@class='Dictionary']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null );
if(dictionaryTable.singleNodeValue)
{
	//within this table, find all TDs that are third amonst their siblings.
	undesirables = document.evaluate( "//tbody/tr/*[3]", dictionaryTable.singleNodeValue, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null );

	//for each one of these TDs...hide them!
	for(i=0;i<undesirables.snapshotLength;i++)
	{
		undesirables.snapshotItem(i).style.display="none";
		undesirables.snapshotItem(i).setAttribute("id","KC101NoRomaja"+unsafeWindow.romanizationCount++);
	}
	//build a notification to tell the user that this table has been modified.
	notification = document.createElement("div");
	toggleLink = document.createElement("a");
	toggleLink.setAttribute("onclick", "toggleRomaja();");
	toggleLink.appendChild( document.createTextNode("The following table has had "+(i-1).toString()+" Romanized words removed. Click here to toggle the visibility.") );
	toggleLink.style.fontStyle = "italic";
	notification.appendChild(toggleLink);
	//place the notification directly above the modified table. 
	dictionaryTable.singleNodeValue.parentNode.insertBefore(notification,dictionaryTable.singleNodeValue);
}