Effect: (click it will go to the page)
Created
August 6, 2022 10:19
-
-
Save dipsywong98/5a951db953f07194cc1827bb91b5532f to your computer and use it in GitHub Desktop.
Inject github page link tampermonkey script
This file contains hidden or 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
// ==UserScript== | |
// @name Inject github page link | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author Dipsy Wong | |
// @match https://github.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const el = document.querySelector('a[data-pjax="#repo-content-pjax-container"]') | |
const [_,username,repoName] = el.href.match(/^https:\/\/github.com\/(.*)\/(.*)$/) | |
let url = `${username}.github.io` | |
url = `https://${url}/` + (repoName === url ? '' : repoName) | |
const a = document.createElement('a') | |
a.className+=' Label Label--secondary v-align-middle mr-1' | |
a.href = url | |
a.innerHTML = 'gh-page' | |
el.parentNode.parentNode.append(a) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment