contentEditable

Applies contentEditable when F7 is pressed

  1. // ==UserScript==
  2. // @name contentEditable
  3. // @version 1.1
  4. // @description Applies contentEditable when F7 is pressed
  5. // @match *://*/*
  6. // @grant none
  7. // @namespace https://greasyfork.org/users/117222
  8. // ==/UserScript==
  9.  
  10. var j=118;
  11. // Set "j" to any keyCode you wish.
  12. // KeyCode 118 is the [ F7 ] key.
  13.  
  14. (function() {
  15. var a=false,b=document.body;
  16. window.addEventListener('keydown',function(e){
  17. if(e.keyCode==j){
  18. if(!a){
  19. b.setAttribute('contentEditable',"");
  20. b.setAttribute("spellcheck","false");
  21. }else{
  22. b.removeAttribute('contentEditable');
  23. b.removeAttribute('spellcheck');
  24. }
  25. a=!a;
  26. }
  27. });
  28. })();