Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -987,6 +987,28 @@ custom_css = """
|
|
| 987 |
|
| 988 |
/* --- 隱藏用注入區塊 --- */
|
| 989 |
#custom-css-injector { display: none !important; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 990 |
"""
|
| 991 |
|
| 992 |
# 改用 Gradio 6 官方推薦的 JavaScript 注入法 (繞過棄用的 head 參數)
|
|
@@ -998,15 +1020,16 @@ function() {
|
|
| 998 |
window.history.replaceState({path: newUrl}, "", newUrl);
|
| 999 |
}
|
| 1000 |
|
| 1001 |
-
// 終極暴力清除 Hugging Face Logo
|
| 1002 |
setInterval(function() {
|
| 1003 |
-
// 1. 殺死特定自訂標籤
|
| 1004 |
-
document.querySelectorAll('huggingface-workspace-badge, huggingface-space-badge').forEach(el => el.remove());
|
| 1005 |
|
| 1006 |
-
// 2.
|
| 1007 |
-
document.querySelectorAll('a[href
|
| 1008 |
-
|
| 1009 |
-
|
|
|
|
| 1010 |
parentContainer.remove();
|
| 1011 |
} else {
|
| 1012 |
el.remove();
|
|
@@ -1015,7 +1038,12 @@ function() {
|
|
| 1015 |
|
| 1016 |
// 3. 殺死 Built with Gradio 頁尾
|
| 1017 |
document.querySelectorAll('footer').forEach(el => el.remove());
|
| 1018 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1019 |
|
| 1020 |
return [];
|
| 1021 |
}
|
|
|
|
| 987 |
|
| 988 |
/* --- 隱藏用注入區塊 --- */
|
| 989 |
#custom-css-injector { display: none !important; }
|
| 990 |
+
|
| 991 |
+
/* --- 終極隱藏 HF 頂部導覽列與 Badge --- */
|
| 992 |
+
huggingface-space-header,
|
| 993 |
+
huggingface-workspace-badge,
|
| 994 |
+
huggingface-space-badge,
|
| 995 |
+
iframe[src*="huggingface"],
|
| 996 |
+
div.fixed.top-0.z-50 {
|
| 997 |
+
display: none !important;
|
| 998 |
+
opacity: 0 !important;
|
| 999 |
+
visibility: hidden !important;
|
| 1000 |
+
pointer-events: none !important;
|
| 1001 |
+
height: 0 !important;
|
| 1002 |
+
width: 0 !important;
|
| 1003 |
+
position: absolute !important;
|
| 1004 |
+
z-index: -99999 !important;
|
| 1005 |
+
}
|
| 1006 |
+
|
| 1007 |
+
/* 確保不影響頁面本體,但強制覆蓋 body 的 padding-top (HF Header有時會推擠版面) */
|
| 1008 |
+
body {
|
| 1009 |
+
padding-top: 0 !important;
|
| 1010 |
+
margin-top: 0 !important;
|
| 1011 |
+
}
|
| 1012 |
"""
|
| 1013 |
|
| 1014 |
# 改用 Gradio 6 官方推薦的 JavaScript 注入法 (繞過棄用的 head 參數)
|
|
|
|
| 1020 |
window.history.replaceState({path: newUrl}, "", newUrl);
|
| 1021 |
}
|
| 1022 |
|
| 1023 |
+
// 終極暴力清除 Hugging Face Logo、導覽列、帳號與 Gradio 頁尾
|
| 1024 |
setInterval(function() {
|
| 1025 |
+
// 1. 殺死特定自訂標籤 (包含整個 HF Header)
|
| 1026 |
+
document.querySelectorAll('huggingface-space-header, huggingface-workspace-badge, huggingface-space-badge').forEach(el => el.remove());
|
| 1027 |
|
| 1028 |
+
// 2. 尋找所有指向 Hugging Face 的連結 (包含帳號與 Logo)
|
| 1029 |
+
document.querySelectorAll('a[href*="huggingface.co"]').forEach(el => {
|
| 1030 |
+
// 往上找,只要找到頂層容器 (header, fixed, absolute) 且不屬於 gradio-container,就整塊刪掉
|
| 1031 |
+
let parentContainer = el.closest('div.fixed, header, div.absolute, huggingface-space-header');
|
| 1032 |
+
if (parentContainer && !parentContainer.closest('.gradio-container')) {
|
| 1033 |
parentContainer.remove();
|
| 1034 |
} else {
|
| 1035 |
el.remove();
|
|
|
|
| 1038 |
|
| 1039 |
// 3. 殺死 Built with Gradio 頁尾
|
| 1040 |
document.querySelectorAll('footer').forEach(el => el.remove());
|
| 1041 |
+
|
| 1042 |
+
// 4. 清除可能殘留的 body 空白高度推擠
|
| 1043 |
+
if (document.body.style.paddingTop) {
|
| 1044 |
+
document.body.style.paddingTop = '0px';
|
| 1045 |
+
}
|
| 1046 |
+
}, 200); // 提升巡邏頻率至 0.2 秒,達到秒殺效果
|
| 1047 |
|
| 1048 |
return [];
|
| 1049 |
}
|