Skip to content

Instantly share code, notes, and snippets.

@winkler1
Last active November 11, 2015 15:33
Show Gist options
  • Save winkler1/429721aa47b61f454988 to your computer and use it in GitHub Desktop.
Save winkler1/429721aa47b61f454988 to your computer and use it in GitHub Desktop.
Find usages
Logic:
- Look at URL. If it's github, react-components.com, react.rocks or npmjs.com, use the last part of the URL as module name.
- Else, get selected text on page as URL.
- Else, ASK.
- THEN: Run a Github query for uses of the module in package.json.
// BOOKMARKLET
javascript:(function(){
var e,t,n,r=window.getSelection().toString();r||(e=location.href.split("/"),t=e[2],r="github.com"===t||"react-components.com"==t||"react.rocks"==t||"npmjs.com"==t?e[e.length-1]:prompt("What module?")),n="https://github.com/search?utf8=%E2%9C%93&q="+r+"+filename%3Apackage+language%3AJSON&type=Code&ref=searchresults",location.href=n;})();
varvar module=window.getSelection().toString();
if (!module) {
var sections=location.href.split('/');
var domain=sections[2];
if (domain==='github.com' || domain=='react-components.com' || domain == 'react.rocks' || domain == 'npmjs.com') {
module=sections[sections.length-1];
}
else { module=prompt("What module?")}
}
console.log('Looking for uses of ', module);
var url="https://github.com/search?utf8=%E2%9C%93&q="+ module +"+filename%3Apackage+language%3AJSON&type=Code&ref=searchresults";
location.href=url;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment