Skip to content

Commit 7bc420a

Browse files
committed
Append CoderStats link rather than cloning posibly non-existing link item.
Don't listen on DOMSubtreeModified event
1 parent 0ca9909 commit 7bc420a

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

coderstats/data/coderstats.js

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
var link = document.getElementsByClassName('octicon-link')[0],
2-
path = document.location.pathname,
1+
var path = document.location.pathname,
32
details,
43
login,
54
url;
@@ -11,7 +10,6 @@ if (m = path.match(/^\/([\w-]+)\??.*?/)) {
1110
details = document.getElementsByClassName('vcard-details');
1211
if (details.length > 0) {
1312
addLink();
14-
document.addEventListener('DOMSubtreeModified', navClick, false);
1513
}
1614
}
1715
}
@@ -26,24 +24,16 @@ function addLink() {
2624
li.setAttribute('class', 'vcard-detail pt-1');
2725
li.setAttribute('itemprop', 'url');
2826

29-
var a = document.createElement('a');
27+
let span = document.createElement('span');
28+
span.setAttribute('class', 'octicon');
29+
span.setAttribute('style', 'margin-top:-2px;');
30+
span.textContent = "📊";
31+
li.appendChild(span)
32+
33+
let a = document.createElement('a');
3034
a.setAttribute('href', url);
3135
a.textContent = "CoderStats('" + login + "')";
3236

33-
var svg = link.cloneNode();
34-
svg.appendChild(link.childNodes[0].cloneNode())
35-
36-
li.appendChild(svg);
3737
li.appendChild(a);
3838
details[0].appendChild(li);
39-
}
40-
41-
42-
// https://github.com/KyroChi/GitHub-Profile-Fluency/blob/Google-Chrome/chrome/content.js
43-
function navClick() {
44-
document.removeEventListener('DOMSubtreeModified', navClick);
45-
setTimeout(function() {
46-
addLink();
47-
document.addEventListener('DOMSubtreeModified', navClick, false);
48-
}, 500);
49-
}
39+
}

0 commit comments

Comments
 (0)