Skip to content

Commit

Permalink
Rely on the pull-request btn instead of readme to detect the home page
Browse files Browse the repository at this point in the history
  • Loading branch information
joaodelgado committed Dec 21, 2017
1 parent 65d66c2 commit dd72135
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/js/Github.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ export default class GitHub {
}

inRepoHome() {
return !!document.querySelector(this.readmeSelector());
return !!document.querySelector(this.pullRequestButtonSelector());
}

readmeSelector() {
return '#readme article';
pullRequestButtonSelector() {
return '.new-pull-request-btn';
}

fileNavigatorSelector() {
return '.file-navigation';
}

_repoHomePath() {
Expand Down
6 changes: 3 additions & 3 deletions src/js/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ function init() {

// Create base elements
if (!document.getElementById(BUTTONS_ID)) {
const buttonsBase = document.querySelector('.new-pull-request-btn');
const buttonsBase = document.querySelector(github.pullRequestButtonSelector());
const buttonsWrapper = document.createElement('div');
buttonsWrapper.id = BUTTONS_ID;
buttonsBase.after(buttonsWrapper);
}

if (!document.getElementById(BADGES_ID)) {
const badgesBase = document.querySelector('.file-navigation');
const badgesBase = document.querySelector(github.fileNavigatorSelector());
const badgesWrapper = document.createElement('div');
badgesWrapper.id = BADGES_ID;
badgesBase.after(badgesWrapper);
Expand All @@ -71,5 +71,5 @@ const listener = () => {
init();
};

document.arrive(github.readmeSelector(), listener);
document.arrive(github.pullRequestButtonSelector(), listener);
listener();

0 comments on commit dd72135

Please sign in to comment.