From 029b1e619e431134e8a706ee7877f2a254453876 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 25 Nov 2015 14:48:31 -0500 Subject: [PATCH] nitrpg: update the userscript to the new github layout and fix todos Signed-off-by: Jean Privat --- contrib/nitrpg/nitrpg.user.js | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/contrib/nitrpg/nitrpg.user.js b/contrib/nitrpg/nitrpg.user.js index e372fc1..7e27fa1 100644 --- a/contrib/nitrpg/nitrpg.user.js +++ b/contrib/nitrpg/nitrpg.user.js @@ -2,32 +2,26 @@ // @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 +// @include https://github.com/* +// @downloadURL https://github.com/nitlang/nit/raw/master/contrib/nitrpg/nitrpg.user.js +// @version 2 // @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'); +var nav = document.getElementsByClassName('reponav'); +if (!nav || !nav[0]) return; -// The new tab -var html = '
  • \ - \ - Github RPG\ - \ -
  • '; +// The current repo to link +var repo = $("meta[name='octolytics-dimension-repository_nwo']").attr("content"); +//repo = "nitlang/nit"; +if (!repo) return; -// Create a new list to put the new tab -var group = document.createElement('ul'); -group.setAttribute( 'class', 'sunken-menu-group' ); -group.innerHTML = html; +// The content of the new tab +var html = ' Github RPG'; +//html = '

    x

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