-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcoderstats.js
More file actions
36 lines (30 loc) · 1004 Bytes
/
coderstats.js
File metadata and controls
36 lines (30 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
let path = document.location.pathname,
details,
login,
url;
if (m = path.match(/^\/([\w-]+)\??.*?/)) {
login = m[1].trim();
if (-1 === ['timeline', 'languages', 'blog', 'explore'].indexOf(login)) {
url = 'https://coderstats.github.io/github#' + login;
details = document.getElementsByClassName('vcard-details');
if (details.length > 0) {
addLink();
}
}
}
function addLink() {
let li = document.createElement('li');
li.setAttribute('id', 'coderstats');
li.setAttribute('class', 'vcard-detail pt-1');
li.setAttribute('itemprop', 'url');
let span = document.createElement('span');
span.setAttribute('class', 'octicon');
span.setAttribute('style', 'margin-top:-2px;');
span.textContent = "📊";
li.appendChild(span)
let a = document.createElement('a');
a.setAttribute('href', url);
a.textContent = "CoderStats('" + login + "')";
li.appendChild(a);
details[0].appendChild(li);
}