Nexus Clash Bullhorn Safety

Disables bullhorn button until something is typed in bullhorn speech box.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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        Nexus Clash Bullhorn Safety
// @namespace   http://userscripts.org/users/125692
// @description Disables bullhorn button until something is typed in bullhorn speech box.
// @include     http://www.nexusclash.com/modules.php?name=Game*
// @include     http://nexusclash.com/modules.php?name=Game*
// @exclude        http://nexusclash.com/modules.php?name=Game&op=disconnect
// @exclude        http://www.nexusclash.com/modules.php?name=Game&op=disconnect
// @version     1
// @grant       none
// ==/UserScript==
(function() {
 var bullhornform= document.evaluate("//form[@name='bullhorn']", document, null,
	    XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); 
  if (bullhornform.snapshotLength > 0){
    //we have a bullhorn so preceed
    
    bullhornform=bullhornform.snapshotItem(0);//assume bullhorn form we want is first one.
    var bullhornbutton=bullhornform.firstElementChild;
    bullhornbutton.disabled=true;
    var bullhornspeechbox=bullhornbutton.nextElementSibling;
    var enablebullhorn=function(e) {
        var button=e.target.previousElementSibling;
        if (e.target.value!=""){
            button.disabled=false;
        }
        else{
            button.disabled=true;
        }
    }
    //bullhornspeechbox.addEventListener("keyup",enablebullhorn,false);
    bullhornspeechbox.addEventListener("input",enablebullhorn,false);
    
  }
//EOF
})();