Grok Think Shortcut

Activate Grok Thinking mode with Ctrl+Cmd+T (macOS) or Ctrl+Alt+T (Windows/Linux)

  1. // ==UserScript==
  2. // @name Grok Think Shortcut
  3. // @namespace nisc
  4. // @version 2025.06.09-A
  5. // @description Activate Grok Thinking mode with Ctrl+Cmd+T (macOS) or Ctrl+Alt+T (Windows/Linux)
  6. // @homepageURL https://github.com/nisc/grok-userscripts/
  7. // @author nisc
  8. // @match https://grok.com/*
  9. // @icon https://grok.com/favicon.ico
  10. // @run-at document-end
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. /**
  18. * Configuration object containing all constants used in the script
  19. * KEYS: Keyboard shortcut configuration
  20. * BUTTON: Settings for finding the target button
  21. */
  22. const CONFIG = {
  23. KEYS: {
  24. KEY: 't',
  25. REQUIRES_SHIFT: false,
  26. REQUIRES_ALT: false,
  27. REQUIRES_CTRL: true
  28. },
  29. BUTTON: {
  30. TEXT: 'Think'
  31. }
  32. };
  33.  
  34. /**
  35. * Handles keyboard shortcut for toggling Think mode
  36. *
  37. * Shortcut behavior:
  38. * - Windows/Linux: Ctrl + Shift + D
  39. * - macOS: Cmd + Shift + D
  40. *
  41. * The handler will:
  42. * 1. Check if the correct key combination is pressed
  43. * 2. Prevent default browser behavior
  44. * 3. Find and click the Think button if it exists
  45. */
  46. function handleThinkShortcut(event) {
  47. // Check if it's the right key combination
  48. const isMac = navigator.userAgent.includes('Mac');
  49. const isModifierPressed = isMac ? event.metaKey : event.ctrlKey;
  50.  
  51. if (event.key.toLowerCase() === CONFIG.KEYS.KEY &&
  52. isModifierPressed &&
  53. event.shiftKey === CONFIG.KEYS.REQUIRES_SHIFT &&
  54. event.altKey === CONFIG.KEYS.REQUIRES_ALT &&
  55. event.ctrlKey === CONFIG.KEYS.REQUIRES_CTRL) {
  56.  
  57. // Stop any default browser behavior
  58. event.preventDefault();
  59. event.stopPropagation();
  60.  
  61. // Find and click the Think button
  62. const thinkButton = Array.from(document.querySelectorAll('button'))
  63. .find(button => button.textContent.trim() === CONFIG.BUTTON.TEXT);
  64.  
  65. if (thinkButton) {
  66. thinkButton.click();
  67. }
  68. }
  69. }
  70.  
  71. // Listen for keyboard shortcuts anywhere on the page
  72. document.addEventListener('keydown', handleThinkShortcut);
  73. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址