<commit_before>// ==UserScript==
// @name        Github.com - Add RPG tab
// @namespace   nitlanguage/github/rpg
// @description Adds a "Github RPG" Tab at the end of the tabs.
// @include     https://github.com/nitlang/nit*
// @version     1
// @grant       none
// ==/UserScript==

/* This script is a userscript to use in browsers with the appropriate plug-in to add a "RPG" tab on the github site.
*/

/* TODO:
 * Link to the player page (if logged and is a player)
 * Link to other games (not just `nitlang/nit` but other)
*/

// The nav bar with tabs
var nav = document.getElementsByClassName('repo-nav');

// The new tab
var html = '<li class="tooltipped tooltipped-w" aria-label="Github RPG">\
    <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">\
          <span class="octicon octicon-ruby"></span> <span class="full-word">Github RPG</span>\
          <img alt="" class="mini-loader" height="16" src="https://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif" width="16">\
</a></li>';

// Create a new list to put the new tab
var group = document.createElement('ul');
group.setAttribute( 'class', 'sunken-menu-group' );
group.innerHTML = html;

nav[0].appendChild(group);
<commit_msg>nitrpg: update the userscript to the new github layout and fix todos<commit_after>// ==UserScript==
// @name        Github.com - Add RPG tab
// @namespace   nitlanguage/github/rpg
// @description Adds a "Github RPG" Tab at the end of the tabs.
// @include     https://github.com/*
// @downloadURL https://github.com/nitlang/nit/raw/master/contrib/nitrpg/nitrpg.user.js
// @version     2
// @grant       none
// ==/UserScript==

// The nav bar with tabs
var nav = document.getElementsByClassName('reponav');
if (!nav || !nav[0]) return;

// The current repo to link
var repo = $("meta[name='octolytics-dimension-repository_nwo']").attr("content");
//repo = "nitlang/nit";
if (!repo) return;

// The content of the new tab
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>';
//html = '<p><span>x</span></p>';

// Inject the new tab
var div = document.createElement('div');
div.innerHTML = html;
nav[0].append(div.firstChild);

{'fraction_non_alphanumeric': 0.16997518610421836, 'fraction_numerical': 0.004549214226633582, 'mean_word_length': 3.651923076923077, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6411831', 'n_tokens_mistral': 807, 'n_tokens_neox': 778, 'n_words': 223}