Clear Input

Clear text of text inputs when middle clicked.

  1. // ==UserScript==
  2. // @name Clear Input
  3. // @description Clear text of text inputs when middle clicked.
  4. // @namespace 855495743
  5. // @author Jenie
  6. // @include *
  7. // @version 0.3
  8. // @grant none
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. var inputs = Array.prototype.slice.call(document.querySelectorAll('input, textarea'));
  13. inputs.forEach(function(i) {
  14. i.addEventListener("mousedown", function(e) {
  15. if (e.which === 2) {
  16. e.preventDefault();
  17. e.target.value = '';
  18. e.target.focus();
  19. }
  20. });
  21. });