Skip to content

Commit 0a62c84

Browse files
committed
fix: 警告文字改成黑色,修复一些元素路径 (close #243)
1 parent ea6b132 commit 0a62c84

2 files changed

Lines changed: 32 additions & 27 deletions

File tree

github-repo-size-view/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# **🛠️ GitHub Repo Size+ 升级日志**
22

3+
### **📅 2026.3.5.1**
4+
5+
**修复**: 警告文字改成黑色,修复一些元素路径<br>
6+
7+
---
8+
39
### **📅 2025.5.27.1**
410

511
**Fix**: 修复在储存库页面不显示快捷跳转按钮的问题[#137](https://github.com/ChinaGodMan/UserScripts/issues/137),其他脚本导致页面元素变化<br>

github-repo-size-view/github-repo-size-view.user.js

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
// @description:zh-HK 🤠 倉庫顯示大小:在 GitHub 的程式碼搜尋、倉庫搜尋、議題頁面、使用者倉庫清單和儲存庫頁面上,倉庫名稱旁會顯示該倉庫的大小,方便使用者快速了解倉庫的規模,最佳化選擇。不活躍開發警告:如果某個倉庫在過去六個月內沒有更新,系統會在倉庫的頂部添加提示,提醒用戶該倉庫不活躍,並顯示最後一次更新的時間。這有助於使用者判斷倉庫的活躍程度和維護狀況。倉庫內快速跳轉:在瀏覽倉庫時,使用者可以方便地查看該使用者的所有倉庫列表,提供一個快速跳到不同倉庫的入口。用戶可以快速找到和存取感興趣的其他項目,提高工作效率。使用情境:開發者:可以透過顯示倉庫大小和活躍警告,快速篩選出適當的庫進行開發,避免使用不再維護的項目。專案管理者:透過快速跳轉功能,方便管理和協調多個項目,提高工作效率。學習者:在學習新科技時,可以更方便地找到相關的開源項目,快速查看專案的活躍程度和規模。 🤠
8181
// @description:fr-CA 🤠 Taille d’affichage de l’entrepôt : sur la recherche de code, la recherche d’entrepôt, la page de problèmes, la liste d’entrepôts d’utilisateurs et la page de référentiel de GitHub, la taille de l’entrepôt sera affichée à côté du nom de l’entrepôt, permettant aux utilisateurs de comprendre rapidement l’échelle de l’entrepôt et d’optimiser leur sélection. Avertissement de développement inactif : si un référentiel n’a pas été mis à jour au cours des six derniers mois, le système ajoutera une invite en haut du référentiel pour rappeler aux utilisateurs que le référentiel est inactif et affichera l’heure de la dernière mise à jour. Cela aide les utilisateurs à déterminer l’activité et l’état de maintenance de l’entrepôt. Saut rapide dans l’entrepôt : lors de la navigation dans l’entrepôt, l’utilisateur peut facilement consulter la liste de tous les entrepôts de l’utilisateur, offrant ainsi une entrée pour accéder rapidement à différents entrepôts. Les utilisateurs peuvent trouver et accéder rapidement à d’autres projets d’intérêt, améliorant ainsi l’efficacité du travail. Scénarios d’utilisation : Développeurs : en affichant la taille de l’entrepôt et les avertissements actifs, vous pouvez rapidement filtrer les bibliothèques appropriées pour le développement et éviter d’utiliser des projets qui ne sont plus maintenus. Gestionnaire de projet : grâce à la fonction de saut rapide, il est facile de gérer et de coordonner plusieurs projets et d’améliorer l’efficacité du travail. Apprenants : lorsqu’ils apprennent de nouvelles technologies, ils peuvent plus facilement trouver des projets open source pertinents et vérifier rapidement l’activité et l’ampleur des projets. 🤠
8282
// @namespace https://github.com/ChinaGodMan/UserScripts
83-
// @version 2026.2.6.1
83+
// @version 2026.3.5.1
8484
// @author mshll & 人民的勤务员 <china.qinwuyuan@gmail.com>
8585
// @match https://github.com/*
8686
// @run-at document-start
@@ -107,7 +107,7 @@
107107
* File Created: 2024/11/24,Sunday 12:38:48
108108
* Author: 人民的勤务员@ChinaGodMan (china.qinwuyuan@gmail.com)
109109
* -----
110-
* Last Modified: 2026/02/06,Friday 19:04:18
110+
* Last Modified: 2026/03/05,Thursday 14:08:47
111111
* Modified By: 人民的勤务员@ChinaGodMan (china.qinwuyuan@gmail.com)
112112
* -----
113113
* License: MIT License
@@ -733,7 +733,7 @@ function renderWarning(timediff) {
733733
color: white;
734734
font-size: 36px;
735735
position: relative;
736-
`
736+
`
737737
)
738738
banner.textContent = translate.renderWarning
739739
const smallTag = document.createElement('div')
@@ -746,7 +746,7 @@ function renderWarning(timediff) {
746746
padding: 5px 10px;
747747
font-size: 14px;
748748
border-top-left-radius: 5px;
749-
`
749+
`
750750
)
751751
smallTag.textContent = timediff
752752
banner.appendChild(smallTag)
@@ -765,8 +765,9 @@ function renderCaution(timediff) {
765765
justify-content: center;
766766
align-items: center;
767767
font-size: 24px;
768+
color: black;
768769
position: relative;
769-
`
770+
`
770771
)
771772
banner.textContent = translate.renderCaution
772773
const smallTag = document.createElement('div')
@@ -779,7 +780,7 @@ function renderCaution(timediff) {
779780
padding: 5px 10px;
780781
font-size: 14px;
781782
border-top-left-radius: 5px;
782-
`
783+
`
783784
)
784785
smallTag.textContent = timediff
785786
banner.appendChild(smallTag)
@@ -962,23 +963,21 @@ function isLoggedInUser(avatar_url) {//从返回的json判断
962963
return false
963964
}
964965
}
966+
function getMReponame() { //获取当前移动设备页面的仓库名
967+
return document.querySelector('#responsive-meta-container .flex-wrap')
968+
}
969+
function getCurrentUserId() {
970+
return document
971+
.querySelector('[data-testid="github-avatar"]')
972+
?.src.match(/\/u\/(\d+)/)?.[1] || null
973+
}
965974
function isLoggedInUser_f() {//NOTE - 比较仓库头像和登录头像中的ID
966-
const imgElement = document.querySelector('.AppHeader-user button span span img')
967-
const repoImgElement = document.querySelector('#repo-title-component > img')
968-
if (imgElement && repoImgElement) {
969-
const imgSrc = imgElement.src
970-
const repoImgSrc = repoImgElement.src
975+
const currentUserId = getCurrentUserId()
976+
const repoImgSrc = document.querySelector('#repo-title-component > img')?.src
971977

972-
const userIdPattern = /\/u\/(\d+)/
973-
const imgUserIdMatch = imgSrc.match(userIdPattern)
974-
const repoUserIdMatch = repoImgSrc.match(userIdPattern)
975-
if (imgUserIdMatch && repoUserIdMatch) {
976-
const imgUserId = imgUserIdMatch[1]
977-
const repoUserId = repoUserIdMatch[1]
978-
return imgUserId === repoUserId
979-
}
980-
}
981-
return false
978+
if (!currentUserId || !repoImgSrc) return false
979+
980+
return repoImgSrc.match(/\/u\/(\d+)/)?.[1] === currentUserId
982981
}
983982
async function getUserRepos(href, header = {}) {
984983
try {
@@ -1042,9 +1041,9 @@ function insertOssInsightButton(owner, repo, usePageHeadActions) {
10421041
const title = `${repo} ${translate.ossinsight}`
10431042
const el = usePageHeadActions
10441043
? document.querySelector('.pagehead-actions')
1045-
: document.querySelector('#responsive-meta-container .d-flex.gap-2.mt-n3.mb-3.flex-wrap')
1044+
: getMReponame()
10461045
if (!el) {
1047-
console.log('github-ossinsight: 没有找到目标元素, 无法添加按钮')
1046+
console.log('github-insertOssInsightButton: 没有找到目标元素, 无法添加按钮')
10481047
return
10491048
}
10501049
const buttonHtml = `<a id="github-ossinsight" href="${targetUrl}" target="_blank" rel="noopener noreferrer" aria-label="${title}" class="btn btn-sm tooltipped tooltipped-s">${svgStr}</a>`
@@ -1061,9 +1060,9 @@ function insertActiveForks(owner, repo, usePageHeadActions) {
10611060
const title = `${repo} ${translate.activeforks}`
10621061
const el = usePageHeadActions
10631062
? document.querySelector('.pagehead-actions')
1064-
: document.querySelector('#responsive-meta-container .d-flex.gap-2.mt-n3.mb-3.flex-wrap')
1063+
: getMReponame()
10651064
if (!el) {
1066-
console.log('github-Active Forks: 没有找到目标元素, 无法添加按钮')
1065+
console.log('github-insertActiveForks: 没有找到目标元素, 无法添加按钮')
10671066
return
10681067
}
10691068
const buttonHtml = `<details class="details-reset details-overlay f5 position-relative "><summary id="active-forks-button-repo" class="btn btn-sm tooltipped tooltipped-s" aria-label="${title}"><a id="github-active-forks" href="https://techgaun.github.io/active-forks/index.html#${owner}/${repo}" target="_blank" > ${svgStr} ${usePageHeadActions ? translate.activeforks_ : ''}</a></details>`
@@ -1084,10 +1083,10 @@ function insertDelBtn(owner, repo, usePageHeadActions, cusClass = 'dialog-show-r
10841083
} else {
10851084
el = usePageHeadActions
10861085
? document.querySelector('.pagehead-actions')
1087-
: document.querySelector('#responsive-meta-container .d-flex.gap-2.mt-n3.mb-3.flex-wrap')
1086+
: getMReponame()
10881087
}
10891088
if (!el) {
1090-
console.log('github-Active Forks: 没有找到目标元素, 无法添加按钮')
1089+
console.log('github-insertDelBtn: 没有找到目标元素, 无法添加按钮')
10911090
return
10921091
}
10931092
if (el.querySelector(`#${cusClass}`)) return

0 commit comments

Comments
 (0)