Skip to content

Commit 9eff6b3

Browse files
Use MutationObserver to account for pjax
1 parent be7b896 commit 9eff6b3

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

contentscript.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
(() => {
2-
let ghCodeDropdown = getDropUL();
3-
ghCodeDropdown.appendChild(openInCodeElement(`${document.URL}.git`));
2+
mutationObserver = window.MutationObserver || window.WebKitMutationObserver;
3+
var observer = new MutationObserver(function(mutations, observer) {
4+
let ghCodeDropdown = getDropUL();
5+
if (ghCodeDropdown != undefined) {
6+
ghCodeDropdown.appendChild(openInCodeElement(`${document.URL}.git`));
7+
}
8+
})
49

10+
observer.observe(document, {
11+
subtree: true,
12+
attributes: true
13+
});
14+
515
function openInCodeElement(repo) {
616
// If the LI is already here, return
717
if (document.getElementById("openincode") != null) return;

0 commit comments

Comments
 (0)