Skip to content

Commit

Permalink
fix: inject buttons only on pull request page (#31)
Browse files Browse the repository at this point in the history
Fixes MRGFY-4496
  • Loading branch information
DouglasBlackwood authored Dec 20, 2024
1 parent 851b97a commit 4ceefad
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/mergify.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,18 @@ function buildMergifySectionForNewMergeBox () {
}


function isGitHubPullRequestPage() {
var url = new URL(document.location.href);
var parts = url.pathname.split("/");
return parts.length >= 5 && parts[3] === 'pull';
}


function tryInject() {
if (!isGitHubPullRequestPage()) {
return
}

var isMergifyEnabledOnTheRepo = document.querySelector('a[href="/apps/mergify"]')
if (!isMergifyEnabledOnTheRepo) {
return
Expand All @@ -234,7 +245,6 @@ function tryInject() {
// New merge box
var detailSection = document.querySelector("div.border:nth-child(2)")
if (detailSection) {
console.log("Injecting Mergify section for new merge box")
detailSection.insertBefore(buildMergifySectionForNewMergeBox(), detailSection.firstChild)
}
}
Expand Down

0 comments on commit 4ceefad

Please sign in to comment.