Created
February 6, 2020 19:55
-
-
Save splintor/d42b5d6fe95361a0a9b9951f6aabe739 to your computer and use it in GitHub Desktop.
GitHub - add search term in search results header
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 GitHub - add search term in search results header | |
| // @namespace http://shmulik.flint.org/ | |
| // @version 0.1 | |
| // @description Make it clear what we were looking for. | |
| // @author Shmulik Flint | |
| // @match https://github.com/search* | |
| // @updateUrl https://gist.github.com/splintor/d42b5d6fe95361a0a9b9951f6aabe739/raw | |
| // @grant none | |
| // ==/UserScript== | |
| 'use strict'; | |
| function addSearchTerm() { | |
| const title = document.querySelector('.codesearch-results .pb-3'); | |
| const input = document.getElementsByName('q')[0]; | |
| if (!title || !input || !input.value) { | |
| setTimeout(addSearchTerm, 1000); | |
| return; | |
| } | |
| const searchTerm = input.value.replace(/org\:\S*/g, '').trim(); | |
| title.insertAdjacentHTML('afterend', '<h4>search term: <span style="color: darkblue">' + searchTerm + '</span></h4>'); | |
| } | |
| addSearchTerm() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment