document.addEventListener('click', function (event) {
  var message, element;

  element = event.target;

  if (matches.call(element, 'a[data-disable-with], button[data-disable-with], input[data-disable-with]')) {
    message = element.getAttribute('data-disable-with');
    if(!!element.value){
      element.value = message;
    }else{
      element.innerHTML = message;
    }
    // timeout is needed because Safari stops the submit if the button is immediately disabled
    setTimeout(function(){
      element.setAttribute('disabled', 'disabled');
    }, 0);
  }
}, false);

@@ -78,31 +78,535 @@
 %0A%0A  
-element = event.target;
+// do not disable on right click. Work on left and middle click%0A  if (event.which == 3) %7B%0A    return;%0A  %7D%0A%0A  element = event.target;%0A%0A  // do not disable if the element is a submit button and its form has invalid input elements.%0A  // since failed validations prevent the form from being submitted, we would lock the form permanently%0A  // by disabling the submit button even though the form was never submitted%0A%0A  if(element.getAttribute(%22type%22) === %22submit%22 && element.form.querySelector(%22:invalid%22) !== null) %7B%0A    return;%0A  %7D
 %0A%0A  

Handle disabling edge cases