Twitter CTRL-T Fix

Prevent Twitter from hijacking keyboard shortcuts like CTRL-T for new tab.

当前为 2014-08-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Twitter CTRL-T Fix
  3. // @namespace Lorne
  4. // @include https://twitter.com/*
  5. // @version 1
  6. // @grant metadata
  7. // @description Prevent Twitter from hijacking keyboard shortcuts like CTRL-T for new tab.
  8. // ==/UserScript==
  9. // Keycode for 'r' and 's' and 't'. Add more to disable other ctrl+X interceptions
  10. ctrlkeycodes = [82, 83, 84];
  11. keycodes = [82, 83, 84];
  12.  
  13. (window.opera ? document.body : document).addEventListener('keydown', function(e) {
  14. allow = true;
  15.  
  16. if (keycodes.indexOf(e.keyCode) != -1)
  17. {
  18. allow = false;
  19. }
  20. if(ctrlkeycodes.indexOf(e.keyCode) != -1 && e.ctrlKey)
  21. {
  22. allow = false;
  23. }
  24. if (! allow)
  25. {
  26. e.cancelBubble = true;
  27. e.stopImmediatePropagation();
  28. }
  29. return false;
  30. }, !window.opera);