Skip to content

Commit ae92503

Browse files
committed
Merge: nitrpg: update the userscript to the new github layout and fix todos
Basically a rewrite, but it works on my computer Pull-Request: #1849 Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
2 parents da3c403 + 029b1e6 commit ae92503

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

contrib/nitrpg/nitrpg.user.js

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,26 @@
22
// @name Github.com - Add RPG tab
33
// @namespace nitlanguage/github/rpg
44
// @description Adds a "Github RPG" Tab at the end of the tabs.
5-
// @include https://github.com/nitlang/nit*
6-
// @version 1
5+
// @include https://github.com/*
6+
// @downloadURL https://github.com/nitlang/nit/raw/master/contrib/nitrpg/nitrpg.user.js
7+
// @version 2
78
// @grant none
89
// ==/UserScript==
910

10-
/* This script is a userscript to use in browsers with the appropriate plug-in to add a "RPG" tab on the github site.
11-
*/
12-
13-
/* TODO:
14-
* Link to the player page (if logged and is a player)
15-
* Link to other games (not just `nitlang/nit` but other)
16-
*/
17-
1811
// The nav bar with tabs
19-
var nav = document.getElementsByClassName('repo-nav');
12+
var nav = document.getElementsByClassName('reponav');
13+
if (!nav || !nav[0]) return;
2014

21-
// The new tab
22-
var html = '<li class="tooltipped tooltipped-w" aria-label="Github RPG">\
23-
<a href="http://nitlanguage.org/rpg/games/nitlang/nit" aria-label="RPG" class="js-selected-navigation-item sunken-menu-item" data-selected-links="repo_settings /nitlang/nit/settings">\
24-
<span class="octicon octicon-ruby"></span> <span class="full-word">Github RPG</span>\
25-
<img alt="" class="mini-loader" height="16" src="https://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif" width="16">\
26-
</a></li>';
15+
// The current repo to link
16+
var repo = $("meta[name='octolytics-dimension-repository_nwo']").attr("content");
17+
//repo = "nitlang/nit";
18+
if (!repo) return;
2719

28-
// Create a new list to put the new tab
29-
var group = document.createElement('ul');
30-
group.setAttribute( 'class', 'sunken-menu-group' );
31-
group.innerHTML = html;
20+
// The content of the new tab
21+
var html = '<a href="http://nitlanguage.org/rpg/games/' + repo + '" class="js-selected-navigation-item reponav-item" data-selected-links="nitrpg"><span class="octicon octicon-ruby"></span> Github RPG</a>';
22+
//html = '<p><span>x</span></p>';
3223

33-
nav[0].appendChild(group);
24+
// Inject the new tab
25+
var div = document.createElement('div');
26+
div.innerHTML = html;
27+
nav[0].append(div.firstChild);

0 commit comments

Comments
 (0)