/
userscript.js
31 lines (28 loc) · 1.11 KB
/
userscript.js
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
/* Add a button to the github repo listing page */
(function($) {
var ghf = 'http://sr3d.github.com/GithubFinder?utm_source=userscript',
m = (new RegExp("github.com\/(.+)","i")).exec(window.location.href),
path = m ? m[1].split('/') : [],
user = path[0],
repo = path[1],
branch = path[3],
li = $('ul.actions li:first')[0],
html = '<li><a href="' + ghf +
'&user_id=' + user +
'&repo=' + repo +'" target=_blank class="minibutton"><span>Browse in GHFinder</span></a></li>';
if(li) {
$(li).before(html);
}
/* for userlisting page */
var repoInfo;
$('.profilecols .repositories h3 a').each(function(index,a) {
repoInfo = $(a).attr('href').split('/');
html = '<a href="' + ghf + '&utm_media=profile_column' +
'&user_id=' + repoInfo[1] +
'&repo=' + repoInfo[2] +
'" target=_blank> ' +
'<img src="http://github.com/sr3d/GithubFinder/raw/master/img/folder_explore.png"/>'
'</a>';
$(a).after(html);
});
})(jQuery);