clear input

clear text of text inputs when middle clicked.

目前為 2015-10-21 提交的版本,檢視 最新版本

  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.1
  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. }
  19. });
  20. });