Skip to content

Instantly share code, notes, and snippets.

@tkrkt
Last active September 26, 2016 02:15
Show Gist options
  • Save tkrkt/cab0b40ffe6edc73c6e3 to your computer and use it in GitHub Desktop.
Save tkrkt/cab0b40ffe6edc73c6e3 to your computer and use it in GitHub Desktop.
Add "MyGists" link to GitHub Gist's header
// ==UserScript==
// @name MyGists
// @namespace jp.tkrkt
// @description Add MyGists Button on Gist
// @include https://gist.github.com/*
// @version 3
// @grant none
// ==/UserScript==
var meta = document.querySelector('meta[name=user-login]');
if (meta){
var user = meta.getAttribute('content');
var container = document.querySelector('.header-nav[role=navigation]');
var li = document.createElement('li');
li.setAttribute('class', 'header-nav-item');
var a = document.createElement('a');
a.setAttribute('class', 'header-nav-link');
a.setAttribute('href', '/' + user);
a.textContent = 'My Gists';
li.appendChild(a);
container.insertBefore(li, container.firstChild);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment