// ==UserScript== // @name Pages to GitHub // @namespace https://greasyfork.org/en/scripts/534709-pages-to-github // @version 0.1.5 // @description Access the GitHub profile from *.github.io site // @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 https://update.greasyfork.icu/scripts/534709/Pages%20to%20GitHub.user.js // @updateURL https://update.greasyfork.icu/scripts/534709/Pages%20to%20GitHub.meta.js // ==/UserScript== (function () { 'use strict'; const host = window.location.hostname; const match = host.match(/^([a-zA-Z0-9-]+)\.github\.io$/); if (!match || !match[1]) return; if (window.top !== window.self) 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; padding: 10px; border-top-left-radius: 8px; border-bottom-left-radius: 8px; font-size: 14px; line-height: 1; font-family: sans-serif; display: flex; align-items: center; cursor: pointer; transition: all 0.3s ease; transform: translateX(calc(100% - 38px)); } .gh-float-button:hover { transform: translateX(0); } .gh-float-button svg { height: 18px; width: 18px; flex-shrink: 0; margin-left: 0; margin-right: 6px; } .gh-float-button svg path { fill: white; } .gh-username { opacity: 0; color: white; 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); })();