您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在 GitHub 任意非编辑页面首次访问时强制刷新一次,解决某些脚本和扩展不生效的问题
// ==UserScript== // @name 自动刷新GitHub页面 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 在 GitHub 任意非编辑页面首次访问时强制刷新一次,解决某些脚本和扩展不生效的问题 // @author klcb2010 // @match https://github.com/* // @grant none // ==/UserScript== (function () { 'use strict'; const REFRESH_FLAG = 'gh_auto_full_refresh_done'; const excludeKeywords = ['edit', 'new', 'settings', 'upload', 'releases/new', 'issues/new', 'pull/new']; function isExcluded(url = location.href) { return excludeKeywords.some(keyword => url.includes(keyword)); } function shouldRefresh() { return !sessionStorage.getItem(REFRESH_FLAG) && !isExcluded(); } function forceFullReload() { sessionStorage.setItem(REFRESH_FLAG, 'true'); console.log('[GitHub Auto Refresh] Forcing full reload:', location.href); setTimeout(() => { try { location.reload(true); } catch (e) { console.warn('reload(true) failed, fallback to normal reload'); location.reload(); } }, 1000); } function resetFlagIfNavigated() { sessionStorage.removeItem(REFRESH_FLAG); console.log('[GitHub Auto Refresh] URL changed, reset flag'); } function onUrlChange(callback) { let lastUrl = location.href; new MutationObserver(() => { if (location.href !== lastUrl) { lastUrl = location.href; callback(); } }).observe(document.body, { childList: true, subtree: true }); } if (shouldRefresh()) { forceFullReload(); } onUrlChange(() => { resetFlagIfNavigated(); if (shouldRefresh()) { forceFullReload(); } }); })();