Last active
January 20, 2025 14:00
-
-
Save tinhochu/a47cf2deb524376dfd3dc69fcc9cc915 to your computer and use it in GitHub Desktop.
LinkedIn Search Bar Focus Shortcut + Tampermonkey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name LinkedIn Search Shortcut | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description Shortcut to open LinkedIn with Cmd+K (Mac) or Ctrl+K (Windows) | |
// @author Tin Ho Chu | |
// @match *://www.linkedin.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Add event listener for keydown events | |
document.addEventListener('keydown', function(event) { | |
// Check for Cmd+K on Mac or Ctrl+K on Windows | |
if ((event.metaKey && event.key === 'k') || (event.ctrlKey && event.key === 'k')) { | |
event.preventDefault(); // Prevent default behavior | |
// Try to focus on the LinkedIn search bar | |
const searchBar = document.querySelector('[data-view-name="search-global-typeahead-input"]'); | |
if (searchBar) { | |
searchBar.focus(); | |
} else { | |
console.warn('Search bar not found on this LinkedIn page.'); | |
} | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment