Skip to content

Instantly share code, notes, and snippets.

@zapplebee
Created July 7, 2020 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zapplebee/8f10185a772ba1f5f021463b497f7cd4 to your computer and use it in GitHub Desktop.
Save zapplebee/8f10185a772ba1f5f021463b497f7cd4 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Show Github Path
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://github.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function onClick(e) {
e.target.select()
document.execCommand("copy");
}
const path = window.location.pathname.split('/').filter(e => e)
const div = document.createElement('div')
div.setAttribute('class', 'Header-item position-relative')
div.innerHTML = `<div class="Header-item"><div class="js-site-search-form"><input type="text" class="form-control header-search-input" style="min-width: 40vw;" value="~/${window.location.host}/${path[0]}/${path[1]}" readonly /></div></div></div>`
const input = div.querySelector('input')
input.addEventListener('click', onClick, false)
const priorSibling = document.querySelector('.Header-item--full')
priorSibling.insertAdjacentElement('afterend', div)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment