xerotic's Character Counter

Gives character count information in Quick Reply area. - Updated by Dr Steve Brule

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name          xerotic's Character Counter
// @namespace     xerotic/hfcharcount
// @description   Gives character count information in Quick Reply area. - Updated by Dr Steve Brule
// @include       https://hackforums.net/showthread.php*
// @include       https://www.hackforums.net/showthread.php*
// @version 	  2.1
// ==/UserScript==

 
regex = /here.*?>/;
revised = "here.<br /> <div id='letscount'>0<br /><span style='color:red'>Too Low!</span></div>";
document.getElementById('quickreply_e').innerHTML= document.getElementById('quickreply_e').innerHTML.replace(regex,revised);
addButtonListener();
 
function addButtonListener(){
  var texts = document.getElementById("message");
  texts.addEventListener('keyup',doCountNow,true);
  texts.addEventListener('keydown',doCountNow,true);
}

function doCountNow(){

	var field = parseInt(document.getElementById('message').value.length);
	var minlimit = 25;
	var maxlimit = 18000;
	// if (field > maxlimit) {
		// document.getElementById('message').value = document.getElementById('message').value.substring(0, maxlimit);
	// } else {
		// document.getElementById('letscount').innerHTML = maxlimit - document.getElementById('message').value.length;
	// }
	if (field < minlimit) {
		document.getElementById('letscount').innerHTML = field+'<br /><span style="color:red">Too Low!</span>'
	}
	else if (field > maxlimit) {
		document.getElementById('letscount').innerHTML = field+'<br /><span style="color:red">Too High!</span>'
	}
	else {
		document.getElementById('letscount').innerHTML = field+'<br /><span style="color:green">Okay To Post!</span>'
	}

}