Search Box Keyboard Shortcut for General Websites

Adds a keyboard shortcut to jump to the search box on websites when '/' is pressed

  1. // ==UserScript==
  2. // @name Search Box Keyboard Shortcut for General Websites
  3. // @namespace http://tampermonkey.net/
  4. // @version 5
  5. // @description Adds a keyboard shortcut to jump to the search box on websites when '/' is pressed
  6. // @author Lak
  7. // @match https://www.google.com/*
  8. // @match https://studio.youtube.com/*
  9. // @match https://www.jstor.org/*
  10. // @match https://www.urbandictionary.com/*
  11. // @match https://books.google.com/*
  12. // @match https://archive.org/*
  13. // @match https://pubmed.ncbi.nlm.nih.gov/*
  14. // @match https://support.google.com/*
  15. // @match https://onlinelibrary-wiley-com.proxy.library.upenn.edu/*
  16. // @match https://wiki.pmacs.upenn.edu/*
  17. // @match https://store.steampowered.com/*
  18. // @match https://www.workday.upenn.edu/*
  19. // @match https://myaccount.google.com/*
  20. // @match https://*.stackexchange.com/*
  21. // @match https://www.amazon.com/*
  22. // @match https://www.tampermonkey.net/*
  23. // @match https://chat.openai.com/*
  24. // @match https://www.w3schools.com/*
  25. // @match https://www.overleaf.com/*
  26. // @match https://onlinelibrary.wiley.com/*
  27. // @match https://www.wolframalpha.com/*
  28. // @match https://www.netflix.com/*
  29. // @match https://libgen.is/*
  30. // @match https://arxiv.org/*
  31. // @match https://fmoviesz.to/*
  32. // @match https://www.biorxiv.org/*
  33. // @match https://www.userscript.zone/*
  34. // @match https://gist.github.com/*
  35. // @match https://docs.github.com/*
  36. // @match https://www.bing.com/*
  37. // @match https://poe.com/*
  38. // @match https://www.kaggle.com/*
  39. // @match https://www.myworkday.com/*
  40. // @match https://duckduckgo.com/*
  41. // @match https://rumble.com/*
  42. // @match https://kick.com/*
  43. // @match https://gf.qytechs.cn/*
  44. // @match https://openuserjs.org/*
  45. // @match https://banned.video/*
  46. // @match https://canvas.upenn.edu/*
  47. // @match https://huggingface.co/*
  48. // @match https://www.banned.video/*
  49. // @match https://developer.chrome.com/*
  50. // @match https://stackoverflow.com/*
  51. // @exclude https://www.google.com/finance/*
  52. // @grant none
  53. // @license MIT
  54. // ==/UserScript==
  55.  
  56.  
  57.  
  58. (function() {
  59. 'use strict';
  60.  
  61. document.addEventListener('keydown', function(e) {
  62. // target the specific elements for the search boxes on websites
  63. const searchBox = document.querySelector('.searchboxinput, textarea[aria-label="Search"], input[id="query-input"], input[type="text"], input[id="searchform"], input[type="Search"], textarea[inputmode="search"], .js-search-input.search__input--adv, .header-search-field, input[enterkeyhint="go"], input[aria-label="Search"], input[aria-label="Search for stocks, ETFs & more"]');
  64.  
  65.  
  66. if (e.key === '/' && searchBox && document.activeElement !== searchBox) {
  67. e.preventDefault();
  68. searchBox.focus();
  69. searchBox.setSelectionRange(searchBox.value.length, searchBox.value.length);
  70. }
  71. });
  72. })();

QingJ © 2025

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