Invisible Typer

Type an invisible character when pressing CTRL + Space.

当前为 2016-12-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Invisible Typer
  3. // @namespace Royalgamer06
  4. // @version 0.2
  5. // @description Type an invisible character when pressing CTRL + Space.
  6. // @author Royalgamer06
  7. // @include *
  8. // @exclude file://*
  9. // @grant unsafeWindow
  10. // @run-at document-idle
  11. // ==/UserScript==
  12.  
  13. unsafeWindow.onkeydown = function(e) {
  14. if (e.ctrlKey && e.keyCode == 32) {
  15. try {
  16. document.execCommand('insertText', false, String.fromCharCode(8290));
  17. } catch(c) {
  18. try {
  19. document.activeElement.value = document.activeElement.value.slice(0, document.activeElement.selectionStart) + String.fromCharCode(8290) + document.activeElement.value.slice(document.activeElement.selectionEnd);
  20. } catch(c) {}
  21. }
  22. }
  23. };