JvLastPage

Accès à la dernière page de chaque topic par son icône

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey to install this script.

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name           JvLastPage
// @namespace       
// @description    Accès à la dernière page de chaque topic par son icône
// @include        http://www.jeuxvideo.com/forums/0-*
// @version 0.0.1.20140719093338
// ==/UserScript==

function surf(event) {
	var nb = this.parentNode.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.innerHTML;
		nb = parseInt(nb / 20 + 1);
	var url = this.parentNode.nextSibling.nextSibling.getElementsByTagName("a")[0].href;
	if (event.which == 1) url = url.replace(/(\/1\-[0-9]+\-[0-9]+\-)[0-9]+(\-)/g, "$1" + nb + "$2");
	else url = url.replace(/\/1\-([0-9]+\-[0-9]+\-)[0-9]+(\-[^"]+)/g, "/3-" + "$1" + nb + "$2" + "#form_post");
	window.location.href = url;
	return false;
}

function main() {
	var tr = document.getElementById('liste_topics').getElementsByTagName("tr");
	for (var i = 1; i < tr.length; i++) {
		var img = tr[i].getElementsByTagName("td")[0].getElementsByTagName("img")[0];
			img.title = "Left : Dernière page - Right : Répondre";
			img.setAttribute("oncontextmenu", "return false;");
			img.style.cursor = "pointer";
			img.addEventListener("mouseup", surf, false);
	}
}

main();