Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0ca9909

Browse filesBrowse files
committed
show coderstats link after user navigation tab is clicked
1 parent 606a0fd commit 0ca9909
Copy full SHA for 0ca9909

File tree

2 files changed

+43
-20
lines changed
Filter options

2 files changed

+43
-20
lines changed

‎coderstats/data/coderstats.js

Copy file name to clipboard
+42-19Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,49 @@
1-
var path = document.location.pathname;
1+
var link = document.getElementsByClassName('octicon-link')[0],
2+
path = document.location.pathname,
3+
details,
4+
login,
5+
url;
6+
27
if (m = path.match(/^\/([\w-]+)\??.*?/)) {
3-
var login = m[1];
8+
login = m[1].trim();
49
if (-1 === ['timeline', 'languages', 'blog', 'explore'].indexOf(login)) {
5-
var url = 'http://coderstats.net/github/' + login.trim() + '/';
6-
var details = document.getElementsByClassName('vcard-details');
10+
url = 'http://coderstats.net/github/' + login + '/';
11+
details = document.getElementsByClassName('vcard-details');
712
if (details.length > 0) {
8-
var link = document.getElementsByClassName('octicon-link')[0];
13+
addLink();
14+
document.addEventListener('DOMSubtreeModified', navClick, false);
15+
}
16+
}
17+
}
918

10-
var li = document.createElement('li');
11-
li.setAttribute('class', 'vcard-detail pt-1');
12-
li.setAttribute('itemprop', 'url');
1319

14-
var a = document.createElement('a');
15-
a.setAttribute('href', url);
16-
a.textContent = "CoderStats('" + login + "')";
20+
function addLink() {
21+
let cslink = document.getElementById('coderstats');
22+
if (cslink) return;
1723

18-
var svg = link.cloneNode();
19-
svg.appendChild(link.childNodes[0].cloneNode())
24+
var li = document.createElement('li');
25+
li.setAttribute('id', 'coderstats');
26+
li.setAttribute('class', 'vcard-detail pt-1');
27+
li.setAttribute('itemprop', 'url');
2028

21-
li.appendChild(svg);
22-
li.appendChild(a);
23-
details[0].appendChild(li);
24-
}
25-
}
26-
}
29+
var a = document.createElement('a');
30+
a.setAttribute('href', url);
31+
a.textContent = "CoderStats('" + login + "')";
32+
33+
var svg = link.cloneNode();
34+
svg.appendChild(link.childNodes[0].cloneNode())
35+
36+
li.appendChild(svg);
37+
li.appendChild(a);
38+
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+
}

‎coderstats/package.json

Copy file name to clipboardExpand all lines: coderstats/package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "Display a link to the CoderStats page for the currently displayed GitHub user when browsing github.com.",
66
"author": "CoderStats",
77
"license": "MIT",
8-
"version": "1.0.0",
8+
"version": "1.1.0",
99
"homepage": "http://coderstats.net/",
1010
"icon64": "static/logo-64x64.png"
1111
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.