Tiny script which helps you to build better browser extensions for github.com
github.com is a huge web app with millions of visitors every day. To reduce the serve load, some parts are build as a single page app. This means, not every click results in a page reload. This is a big problem for some extension scenarios.
github.com uses pjax which fires an event after replacing the requested page with the previous one. GitHub-inject will invoke the provided callback when pjax:end
is dispatched and you can reinitialize your extension. For simplicity the callback is also executed on the first script execution.
$ npm install --save github-injection
const gitHubInjection = require('github-injection');
gitHubInjection(() => {
const el = window.document.getElementsByClassName('header')[0];
const randomColor = '#' + ((1<<24) * Math.random()|0).toString(16);
el.style.backgroundColor = randomColor;
});
Copyright (c) 2015 Stefan Buck. Licensed under the MIT license.