diff --git a/.gitignore b/.gitignore index 327f723..aebc377 100644 --- a/.gitignore +++ b/.gitignore @@ -139,3 +139,5 @@ vite.config.js.timestamp-* vite.config.ts.timestamp-* TODO.md + +temp/ diff --git a/better-github-nav.user.js b/better-github-nav.user.js index ba87771..d2f166b 100644 --- a/better-github-nav.user.js +++ b/better-github-nav.user.js @@ -2,7 +2,7 @@ // @name Better GitHub Navigation // @name:zh-CN 更好的 GitHub 导航栏 // @namespace https://github.com/ImXiangYu/better-github-nav -// @version 0.1.33 +// @version 0.1.38 // @description Add quick access to Dashboard, Trending, Explore, Collections, and Stars from GitHub's top navigation. // @description:zh-CN 在 GitHub 顶部导航中加入 Dashboard、Trending、Explore、Collections、Stars 快捷入口,常用页面一键直达。 // @author Ayubass @@ -16,7 +16,7 @@ (() => { // src/constants.js - var SCRIPT_VERSION = "0.1.33"; + var SCRIPT_VERSION = "0.1.38"; var CUSTOM_BUTTON_CLASS = "custom-gh-nav-btn"; var CUSTOM_BUTTON_ACTIVE_CLASS = "custom-gh-nav-btn-active"; var CUSTOM_BUTTON_COMPACT_CLASS = "custom-gh-nav-btn-compact"; @@ -169,8 +169,8 @@ align-items: center; gap: 8px; max-width: min(320px, calc(100vw - 16px)); - background: #25292E; - color: #FFFFFF; + background: var(--color-neutral-emphasis-plus, #1f2328); + color: var(--color-fg-on-emphasis, #ffffff); border-radius: 6px; padding: 4px 8px; font-size: 12px; @@ -179,6 +179,9 @@ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'; pointer-events: none; box-sizing: border-box; + box-shadow: var(--color-shadow-medium, 0 8px 24px rgba(0,0,0,0.2)); + border: 1px solid var(--color-border-default, transparent); + text-decoration: none; } .custom-gh-nav-tooltip[hidden] { display: none !important; @@ -187,11 +190,14 @@ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + text-decoration: none; } .custom-gh-nav-tooltip-hint-container { display: inline-flex; align-items: center; flex-shrink: 0; + margin-left: 4px; + text-decoration: none; } .custom-gh-nav-tooltip-kbd { display: inline-flex; @@ -199,28 +205,29 @@ gap: 4px; margin: 0; padding: 0; - border: 0; + border: none !important; + box-shadow: none !important; font: inherit; color: inherit; - background: transparent; + background: transparent !important; + text-decoration: none !important; } .custom-gh-nav-tooltip-chord { - display: inline-flex; - align-items: center; - justify-content: center; - min-width: 16px; - height: 14px; - padding: 2px 4px; + display: inline-block; + vertical-align: middle; + padding: 0 4px; border-radius: 4px; - border: 0; - background: #59636E; - color: #FFFFFF; + background: rgba(110, 118, 129, 0.4); + color: #ffffff; font-size: 11px; font-weight: 400; - line-height: 10px; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'; + line-height: 18px; + font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; text-transform: uppercase; box-sizing: border-box; + border: none !important; + box-shadow: none !important; + text-decoration: none !important; } #${SETTINGS_OVERLAY_ID} { position: fixed; @@ -393,6 +400,8 @@ function setLinkText(aTag, text) { aTag.removeAttribute("aria-describedby"); aTag.setAttribute("aria-label", text); + const icons = aTag.querySelectorAll("svg"); + icons.forEach((icon) => icon.remove()); const innerSpan = aTag.querySelector("span"); if (innerSpan) { innerSpan.textContent = text; diff --git a/package-lock.json b/package-lock.json index 119b280..4bcc89f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "better-github-nav", - "version": "0.1.33", + "version": "0.1.38", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "better-github-nav", - "version": "0.1.33", + "version": "0.1.38", "license": "MIT", "devDependencies": { "esbuild": "^0.27.3" diff --git a/package.json b/package.json index 751443e..769d7af 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "better-github-nav", - "version": "0.1.33", + "version": "0.1.38", "description": "Build tools for the Better GitHub Navigation userscript.", "private": true, "scripts": { diff --git a/src/navigation.js b/src/navigation.js index cddbd78..cf6c021 100644 --- a/src/navigation.js +++ b/src/navigation.js @@ -34,6 +34,10 @@ export function setLinkText(aTag, text) { aTag.removeAttribute('aria-describedby'); aTag.setAttribute('aria-label', text); + // 移除所有已存在的图标(SVG),防止从模板克隆出错误的图标 + const icons = aTag.querySelectorAll('svg'); + icons.forEach(icon => icon.remove()); + const innerSpan = aTag.querySelector('span'); if (innerSpan) { innerSpan.textContent = text; diff --git a/src/styles.js b/src/styles.js index 1ad8084..79e43f7 100644 --- a/src/styles.js +++ b/src/styles.js @@ -42,8 +42,8 @@ export function ensureStyles() { align-items: center; gap: 8px; max-width: min(320px, calc(100vw - 16px)); - background: #25292E; - color: #FFFFFF; + background: var(--color-neutral-emphasis-plus, #1f2328); + color: var(--color-fg-on-emphasis, #ffffff); border-radius: 6px; padding: 4px 8px; font-size: 12px; @@ -52,6 +52,9 @@ export function ensureStyles() { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'; pointer-events: none; box-sizing: border-box; + box-shadow: var(--color-shadow-medium, 0 8px 24px rgba(0,0,0,0.2)); + border: 1px solid var(--color-border-default, transparent); + text-decoration: none; } .custom-gh-nav-tooltip[hidden] { display: none !important; @@ -60,11 +63,14 @@ export function ensureStyles() { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; + text-decoration: none; } .custom-gh-nav-tooltip-hint-container { display: inline-flex; align-items: center; flex-shrink: 0; + margin-left: 4px; + text-decoration: none; } .custom-gh-nav-tooltip-kbd { display: inline-flex; @@ -72,28 +78,29 @@ export function ensureStyles() { gap: 4px; margin: 0; padding: 0; - border: 0; + border: none !important; + box-shadow: none !important; font: inherit; color: inherit; - background: transparent; + background: transparent !important; + text-decoration: none !important; } .custom-gh-nav-tooltip-chord { - display: inline-flex; - align-items: center; - justify-content: center; - min-width: 16px; - height: 14px; - padding: 2px 4px; + display: inline-block; + vertical-align: middle; + padding: 0 4px; border-radius: 4px; - border: 0; - background: #59636E; - color: #FFFFFF; + background: rgba(110, 118, 129, 0.4); + color: #ffffff; font-size: 11px; font-weight: 400; - line-height: 10px; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'; + line-height: 18px; + font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; text-transform: uppercase; box-sizing: border-box; + border: none !important; + box-shadow: none !important; + text-decoration: none !important; } #${SETTINGS_OVERLAY_ID} { position: fixed;