From dd721357e19a08a7ac872ec846ead3ca6a524c3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Delgado?= Date: Thu, 21 Dec 2017 22:17:09 +0000 Subject: [PATCH] Rely on the pull-request btn instead of readme to detect the home page --- src/js/Github.js | 10 +++++++--- src/js/client.js | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/js/Github.js b/src/js/Github.js index a91e1a9..2f6788c 100644 --- a/src/js/Github.js +++ b/src/js/Github.js @@ -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() { diff --git a/src/js/client.js b/src/js/client.js index 9e1c3d0..da2e767 100644 --- a/src/js/client.js +++ b/src/js/client.js @@ -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); @@ -71,5 +71,5 @@ const listener = () => { init(); }; -document.arrive(github.readmeSelector(), listener); +document.arrive(github.pullRequestButtonSelector(), listener); listener();