// ==UserScript== // @name Pages to GitHub // @namespace https://greasyfork.org/en/scripts/ // @version 0.1.0 // @description Visit GitHub profile from *.github.io sites // @author Super Lee (https://github.com/superpung) // @license MIT // @homepageURL https://github.com/superpung/pages2github // @supportURL https://github.com/superpung/pages2github // @match *://*.github.io/* // @icon https://pages.github.com/favicon.ico // @grant none // @downloadURL none // ==/UserScript== (function () { 'use strict'; const host = window.location.hostname; const match = host.match(/^([a-zA-Z0-9-]+)\.github\.io$/); if (!match || !match[1]) return; const username = match[1]; const githubUrl = `https://github.com/${username}`; const style = document.createElement('style'); style.textContent = ` .gh-float-button { position: fixed; top: 20px; right: 0; z-index: 9999; background-color: #24292e; color: white; padding: 10px 10px; border-top-left-radius: 8px; border-bottom-left-radius: 8px; font-size: 14px; font-family: sans-serif; display: flex; align-items: center; cursor: pointer; transition: all 0.3s ease; transform: translateX(70%); } .gh-float-button:hover { transform: translateX(0%); } .gh-float-button img { width: 18px; height: 18px; margin-right: 6px; } .gh-username { opacity: 0; transition: opacity 0.3s ease; white-space: nowrap; } .gh-float-button:hover .gh-username { opacity: 1; } `; document.head.appendChild(style); const button = document.createElement('div'); button.className = 'gh-float-button'; button.innerHTML = ` @${username} `; button.onclick = () => { window.open(githubUrl, '_blank'); }; document.body.appendChild(button); })();