// ==UserScript== // @name Github mirror homepage tranverse // @namespace http://tampermonkey.net/ // @version 0.1 // @description 在Github官网和镜像网站进行转换 Generate a button to trans between GitHub homepage and mirror // @author HuanZhi // @match https://github.com/* // @match https://hub.fgit.cf/* // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function(){ // download by clicking on the button var btn = document.createElement("button"); btn.setAttribute('style', "position:absolute;z-index:1000; right: 50px; top: 50px; height: 28px; background-color: #424649; border: none; color: white; font-size: 16px; cursor: pointer;"); btn.setAttribute('id', "btn"); document.body.appendChild(btn); btn.onmouseover = function() { this.style.backgroundColor="#424649" }; btn.onmouseout = function() { this.style.backgroundColor="#323639" }; var url = window.location.href if(url.includes("github")){ btn.innerText = "原始github网站"; btn.onclick=mirror; }else{ btn.innerText = "镜像网站"; btn.onclick=origin; } } )() function mirror(){ var home_url = window.location.href.replace('https://github.com', 'https://hub.fgit.cf'); window.open(home_url); } function origin(){ var home_url = window.location.href.replace('https://hub.fgit.cf', 'https://github.com'); window.open(home_url); }