Modification books.ru

By ihoru Last update Jun 29, 2008 — Installed 36 times.
// ==UserScript==
// @name           Modification books.ru
// @namespace      http://polyakov.org.ua/greasemonkey/
// @description    Adds links instead buttons. Replaces javascript links into direct links to content
// @include        http://*books.ru/*
// @exclude        http://*books.ru/chapter*

// Author: Ihor Polyakov
// Author site: http://polyakov.org.ua/
// Author e-mail: ihor.polyakov@gmail.com

// ==/UserScript==

// Убить нижнюю никому ненужную часть сайта!
tables = document.getElementsByTagName('table');
tables[0].rows[2].style.display = 'none';

// Убиение белой полосы сверху
tables2 = tables[0].rows[0].cells[0].getElementsByTagName('table');
tables3 = tables2[0].rows[2].cells[0].getElementsByTagName('table');
tables3[0].rows[1].style.display = 'none';
tables3[0].rows[0].cells[0].height = "0"; //схлопнуть опустошонную ячейку

// Сделать ссылки на добавление в корзину прямыми
for (i=0;i<document.forms.length;i++){
	var el = document.forms[i].elements.namedItem('add');
	if (document.forms[i].name=='add2cart' && el && el.name == 'add'){
		//alert('i have changed something');
	    var table = document.forms[i].elements[0].parentNode.parentNode.parentNode.offsetParent;
	    table.rows[0].cells[0].innerHTML = '<a href="?add=' + el.value + '"><img src="/images/add_to_cart_grey.gif" border="0" /></a>';
	    table.rows[1].cells[0].innerHTML = '<a href="?add=' + el.value + '"><img src="/images/button_addtocart.gif" border="0" /></a>';
	}
}
for (i=0; i<document.links.length; ++i)
{
	href = document.links[i].href;
	
	// Оглавление
	if (href.substr(0,15) == 'javascript:sod(')
	{
		id = href.substr(15, href.length-16);
		document.links[i].href = "http://www.books.ru/contents?id=" + id;
	}
	// Заглянуть внутрь
	else if (href.substr(0,16) == 'javascript:chap(')
	{
		id = href.substr(16, href.length-17);
		document.links[i].href = "http://www.books.ru/chapter?id=" + id;
	}
	// Голосование
	else if (href.substr(0,16) == 'javascript:vote(')
	{
		id = href.substr(16, href.length-17);
		document.links[i].href = "http://www.books.ru/vote?id=" + id;
	}
	// Обложка
	else if (href.substr(0,19) == 'javascript:coverf(\'')
	{
		lnk = href.substr(19, href.length-21);
		document.links[i].href = lnk;
	}
	// Report bug
	else if (href.substr(0,17) == 'javascript:bugs("')
	{
		hash = href.substr(17, href.length-17-6);
		document.links[i].href = "http://www.books.ru/bugreport.php?bp=" + hash;
	}
}