Skip to content

Commit 9580bd6

Browse files
author
Stefan Buck
committed
Fix module export and update readme
1 parent 5389f05 commit 9580bd6

File tree

2 files changed

+2
-22
lines changed

2 files changed

+2
-22
lines changed

README.md

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,16 @@
77

88
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.
99

10-
The Github-Injection registers a listener to the dom which detects dom changes. If a significant dom node changed his content, the callback will be executed and you can reinitialize your extension. For simplicity the callback is also executed on the first script execution.
11-
12-
A sample implementation can be found in the [Octo-Linker-Core](https://github.com/octo-linker/core/blob/4a30c6606465e294d1ae1c9ca394ba03368928f7/index.js#L8-L10) package.
10+
GitHub.com uses [pjax](https://github.com/defunkt/jquery-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.
1311

1412
## Install
1513

16-
Bower
17-
```bash
18-
$ bower install --save github-injection
19-
```
20-
21-
Node
2214
```bash
2315
$ npm install --save github-injection
2416
```
2517

2618
## Usage
2719

28-
### Browser
29-
```js
30-
gitHubInjection(() => {
31-
const el = window.document.getElementsByClassName('header')[0];
32-
const randomColor = '#' + ((1<<24) * Math.random()|0).toString(16);
33-
el.style.backgroundColor = randomColor;
34-
});
35-
36-
```
37-
38-
### Node
3920
```js
4021
const gitHubInjection = require('github-injection');
4122

@@ -44,7 +25,6 @@ gitHubInjection(() => {
4425
const randomColor = '#' + ((1<<24) * Math.random()|0).toString(16);
4526
el.style.backgroundColor = randomColor;
4627
});
47-
4828
```
4929

5030

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ const gitHubInjection = cb => {
1616
// Export the gitHubInjection function for **Node.js**
1717
// Otherwise leave it as a global
1818
if (typeof exports !== 'undefined') {
19-
exports.gitHubInjection = gitHubInjection;
19+
exports = module.exports = gitHubInjection;
2020
}

0 commit comments

Comments
 (0)