/github-stars-links

Chrome UserScript that adds a stars badge to github project links

Primary LanguageJavaScriptMIT LicenseMIT

Github Stars

Add Github Stars badges to Github project links.
Activates directly on activateDirectlyOn array. For other websites, press Control + Alt + G

// Defaults +/- to
const activateDirectlyOn = ['stackoverflow.com', 'google.com', 'github.com'];

Example: Google search results

Turn google results for "react github" into:

When googling "react github"

Example: Github Awesome list

Turn sindresorhus awesome-awesome list into:

sindresorhus/awesome

Testing

chrome://extensions/
  • Turn on "Developer mode"
  • Load unpacked
  • Select this folder

Test Urls

CSP Directives

Developer docs

// Suggestion from docs did not help for github.com
const xhr = new XMLHttpRequest();
xhr.open('GET', shieldUrl, true);
xhr.responseType = 'blob';
xhr.onload = function(e) {
  const badge = document.createElement('img');
  badge.src = window.URL.createObjectURL(this.response);
  el.prepend(badge);
};
xhr.send();

Publish

Publishing to the Chrome Web Store

  • Increase version in manifest.json
  • gulp will create ./dist/github-stars.zip

Upload it to the store and pick 3 dots > "Developer Dashboard".

npm install
npm run build

# Or with global Gulp
gulp

# Rebuild on changes
npm run watch

Do need to click reload in chrome://extensions after each change to the code.