Created
November 3, 2009 23:42
-
-
Save cdmoyer/225593 to your computer and use it in GitHub Desktop.
Add a Gists link to the github dashboard.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// github gist linker | |
// Copyright (c) 2009, Chris Moyer (chris@inarow.net) http://inarow.net/ | |
// MIT (http://www.opensource.org/licenses/mit-license.php) licensed. | |
// | |
// | |
// ==UserScript== | |
// @name github gist linker | |
// @namespace http://inarow.net/ | |
// @include http://github.com/* | |
// @description Version 0.5 | |
// | |
// ==/UserScript== | |
(function () { | |
var user = document.location.href.replace(/http:\/\/.*\//, ''); | |
if (user.match(/\//)) return; // bail on non user pages. | |
var dash = document.getElementById('dashboard'); | |
if (!dash) return; | |
var divs = dash.getElementsByTagName('div'); | |
var doss = null; | |
for (var i = 0; i < divs.length; i++) { | |
if (divs[i].className == 'dossier') { | |
doss = divs[i]; | |
break; | |
} | |
} | |
if (!doss) return; | |
divs = dash.getElementsByTagName('div'); | |
buttons = null; | |
for (var i = 0; i < divs.length; i++) { | |
if (divs[i].className == 'buttons') { | |
buttons = divs[i]; | |
break; | |
} | |
} | |
if (!buttons) return; | |
// we've bailed if we couldn't find the user info box. add the button. | |
var href = 'http://gist.github.com/' + user; | |
var d = document.createElement('div'); | |
d.className = "flexipill"; | |
d.style.cssText = "float: right"; | |
d.innerHTML = '<a href="'+href+'"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="background: transparent url(http://assets2.github.com/images/modules/repos/edit_button.png?c6eb0f11e547c1653efd173d7783e6dcc85d4d07) no-repeat; width:24px"></td><td style="background: transparent url(/images/modules/repos/pills/middle.png) repeat-x scroll 0 0;" class="middle"><span style="color:black;">gists</span></td><td><img src="http://assets3.github.com/images/modules/repos/pills/right.png?c6eb0f11e547c1653efd173d7783e6dcc85d4d07" alt="Right"/></td></tr> </tbody></table> </a>'; | |
buttons.appendChild(d); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment