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 2
  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. // Version 2: added F and N (find and new window)
  11. ctrlkeycodes = [70, 78, 82, 83, 84];
  12. keycodes = [70, 78, 82, 83, 84];
  13.  
  14.  
  15. (window.opera ? document.body : document).addEventListener('keydown', function(e) {
  16. reclaim_all = false; // Turn this to true to kill ALL keyboard shortcuts
  17. allow = true;
  18.  
  19. if (keycodes.indexOf(e.keyCode) != -1)
  20. {
  21. allow = false;
  22. }
  23. if(ctrlkeycodes.indexOf(e.keyCode) != -1 && e.ctrlKey)
  24. {
  25. allow = false;
  26. }
  27. if (reclaim_all || (! allow))
  28. {
  29. e.cancelBubble = true;
  30. e.stopImmediatePropagation();
  31. }
  32. return false;
  33. }, !window.opera);