JvLastPage

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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();