Created
December 7, 2023 20:24
-
-
Save ideabrian/0e74625b54c9e7979b71aeb5f5af5ba7 to your computer and use it in GitHub Desktop.
Revisions
-
ideabrian created this gist
Dec 7, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ document.addEventListener('keydown', function(event) { // Define the key codes for navigation and activation const navigateKey = 'ArrowRight'; // Example: Right arrow key for navigation const activateKey = 'q'; // Use 'q' key for activation // Handle navigation if (event.key === navigateKey) { navigateToNextItem(); } // Handle activation if (event.key === activateKey) { activateCurrentItem(); } }); let currentItemIndex = -1; const items = document.querySelectorAll('.cl-search-result'); function navigateToNextItem() { if (items.length === 0) return; // Remove highlight from the current item if (currentItemIndex >= 0 && currentItemIndex < items.length) { items[currentItemIndex].style.backgroundColor = ''; } // Move to the next item currentItemIndex = (currentItemIndex + 1) % items.length; // Highlight the new current item items[currentItemIndex].style.backgroundColor = 'yellow'; } function activateCurrentItem() { if (items.length === 0 || currentItemIndex < 0 || currentItemIndex >= items.length) return; // Find and click the button within the current item const button = items[currentItemIndex].querySelector('button[title="hide posting"]'); if (button) { button.click(); } } // made by @brianball of buildstuff.ai with the help of chatgpt