Skip to content

Commit 4120ebd

Browse files
Fix button placement on GitHub blob page
Place button before the '...' (more options) button.
1 parent b81c6b2 commit 4120ebd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/injectors/github-injector.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,16 @@ abstract class ButtonInjectorBase implements ButtonInjector {
9090
const btn = this.renderButton(currentUrl, openAsPopup);
9191

9292
const btnGroup = actionbar.getElementsByClassName("BtnGroup");
93-
if (btnGroup && btnGroup.length > 0 && btnGroup[0].classList.contains('float-right')){
93+
const detailsBtn = Array.from(actionbar.children)
94+
.filter(child => child.tagName.toLowerCase() === "details" && child.id.endsWith("more-options-details"));
95+
if (btnGroup && btnGroup.length > 0 && btnGroup[0].classList.contains('float-right')) {
9496
actionbar.insertBefore(btn, btnGroup[0]);
97+
} else if (detailsBtn && detailsBtn.length > 0) {
98+
if (detailsBtn[0].previousElementSibling) {
99+
detailsBtn[0].previousElementSibling.classList.remove("mr-2");
100+
}
101+
btn.classList.add("mr-2");
102+
actionbar.insertBefore(btn, detailsBtn[0]);
95103
} else if (this.asFirstChild && actionbar) {
96104
actionbar.insertBefore(btn, actionbar.firstChild);
97105
} else {

0 commit comments

Comments
 (0)