您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
更好地支持文件级用打开github1s
当前为
// ==UserScript== // @name 更好地一键开启github1s页面 // @namespace github // @author cjm // @description 更好地支持文件级用打开github1s // @include https://github.com/ // @match https://github.com/* // @version 2.0.0 // @license MIT // ==/UserScript== function func() { setTimeout(()=>{ const href = `https://github1s.com${location.pathname}` const ele1 = document.getElementById('wocao1'); const ele2 = document.getElementById('wocao1'); if(ele1 || ele2){ ele1.href = href; ele2.href = href; }else{ const btn1 = `<a id="wocao1" class="btn ml-2 d-none d-md-block" style=" background: #f6f8fa; color: #2da44e; display: inline-block !important; width: 48%; text-align: center; margin: 5px; " target="_blank" href="${href}">` + '使用 github1s 打开(新窗口)' + '</a>' const btn2 = `<a id="wocao2" class="btn ml-2 d-none d-md-block" style=" background: #8c7ae6; background: #2da44e; color: #f6f8fa; display: inline-block !important; width: 48%; text-align: center; margin: 5px; " target="_self" href="${href}">` + '使用 github1s 打开(本页)' + '</a>' const parent = document.querySelector('#repository-container-header'); parent.insertAdjacentHTML('beforeBegin', btn1); parent.insertAdjacentHTML('beforeBegin', btn2); } } , 1000) } func(); //修改native以拦截popstate事件 var pushState = history.pushState; history.pushState = function() { var ret = pushState.apply(history, arguments); window.dispatchEvent(new Event("pushstate")); window.dispatchEvent(new Event("locationchangefathom")); return ret; } window.addEventListener("popstate", function() { window.dispatchEvent(new Event("locationchangefathom")) }); window.addEventListener("locationchangefathom", trackPageview) function trackPageview() { func(); }