phpBB Count Posts

Shows number of post in phpbb-thread.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         phpBB Count Posts
// @namespace    http://openuserjs.org/users/ardiman
// @description  Shows number of post in phpbb-thread.
// @description:de-DE  Nummeriert die Beiträge in phpbb-Thread.
// @grant        GM_getValue
// @grant        GM_setValue
// @homepage     https://github.com/ardiman/userscripts/tree/master/phpbbcountposts
// @icon         https://raw.githubusercontent.com/ardiman/userscripts/master/scriptlogo.gif
// @include      */viewtopic.php*
// @exclude      https://www.camp-firefox.de/forum/*
// @license      CC-BY-NC-SA-3.0; https://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
// @license      MIT; https://opensource.org/licenses/MIT
// @supportURL   https://github.com/ardiman/userscripts/issues
// @version      1.0.9
// @date         2017-11-19
// ==/UserScript==

(function() {
	var nodes = document.evaluate(
		"//p[@class='author']",
		document,
		null,
		XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
		null);
	var numberspanposition = GM_getValue("counterposition", -1);
	if (numberspanposition === -1) {
		GM_setValue("counterposition", 0);
		numberspanposition = 0;
	}
	var startingpost = parseInt(get_url_param('start','0'))+1;
	if (startingpost === 1) {
		var lnks = document.evaluate("//h2/a[contains(@href,'&start=')]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE , null);
		if (lnks.snapshotItem(0) != null) startingpost = parseInt(get_url_param('start',lnks.snapshotItem(0).href))+1;
	}
	for(var i=0; i<nodes.snapshotLength; i++) {
		var authornode = nodes.snapshotItem(i);
		var numberspan = document.createElement("span");
		numberspan.setAttribute("class","gmphpbb_CP_numberspan");
		switch (numberspanposition) {
			case 1:
				numberspan.appendChild(document.createTextNode(" #"+(i+startingpost)));
				authornode.appendChild(numberspan);
				break;
			default:
				numberspan.appendChild(document.createTextNode("#"+(i+startingpost)+" "));
				authornode.insertBefore(numberspan,authornode.firstChild.nextSibling);
				break;
		}
	}
})();

function get_url_param( name, searchtype)
{
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	if (searchtype == "0") {
		var results = regex.exec( window.location.href );
	} else {
		var results = regex.exec( searchtype );
	}

	if ( results == null )
		return "0";
	else
		return results[1];
}