Spaces:
Running
Running
Upload skyscraper.html
Browse files- skyscraper.html +21 -4
skyscraper.html
CHANGED
|
@@ -380,18 +380,35 @@
|
|
| 380 |
<script>
|
| 381 |
(function () {
|
| 382 |
function cleanHF() {
|
| 383 |
-
// 只清除 body 直屬的裸文字節點(含 huggingface 等注入內容)
|
| 384 |
Array.from(document.body.childNodes).forEach(function (node) {
|
|
|
|
| 385 |
if (node.nodeType === 3 && node.textContent.trim()) {
|
| 386 |
node.textContent = '';
|
| 387 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 388 |
});
|
| 389 |
}
|
| 390 |
cleanHF();
|
| 391 |
document.addEventListener('DOMContentLoaded', cleanHF);
|
| 392 |
-
//
|
| 393 |
-
|
| 394 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
})();
|
| 396 |
</script>
|
| 397 |
<canvas id="gameCanvas"></canvas>
|
|
|
|
| 380 |
<script>
|
| 381 |
(function () {
|
| 382 |
function cleanHF() {
|
|
|
|
| 383 |
Array.from(document.body.childNodes).forEach(function (node) {
|
| 384 |
+
// 清除裸文字節點
|
| 385 |
if (node.nodeType === 3 && node.textContent.trim()) {
|
| 386 |
node.textContent = '';
|
| 387 |
}
|
| 388 |
+
// 隱藏 HF 注入的未知元素(非我們自己的 DOM)
|
| 389 |
+
if (node.nodeType === 1 && !node.id && node.tagName !== 'CANVAS' && node.tagName !== 'SCRIPT' && !node.classList.contains('ov') && !node.classList.contains('glass') && !node.classList.contains('back-btn') && !node.classList.contains('hidden') && !['gameCanvas', 'hud', 'timer-bar', 'hint-panel', 'bottom-panel', 'start-screen', 'brief-screen', 'tut-modal', 'summary-screen', 'back-btn', 'gameover-screen'].includes(node.id)) {
|
| 390 |
+
// 可能是 HF 注入的元素,強制隱藏
|
| 391 |
+
node.style.display = 'none';
|
| 392 |
+
}
|
| 393 |
});
|
| 394 |
}
|
| 395 |
cleanHF();
|
| 396 |
document.addEventListener('DOMContentLoaded', cleanHF);
|
| 397 |
+
// MutationObserver:即時偵測 HF 異步注入的新節點
|
| 398 |
+
var obs = new MutationObserver(function (mutations) {
|
| 399 |
+
mutations.forEach(function (m) {
|
| 400 |
+
m.addedNodes.forEach(function (node) {
|
| 401 |
+
if (node.parentNode !== document.body) return;
|
| 402 |
+
if (node.nodeType === 3 && node.textContent.trim()) {
|
| 403 |
+
node.textContent = '';
|
| 404 |
+
}
|
| 405 |
+
});
|
| 406 |
+
});
|
| 407 |
+
});
|
| 408 |
+
obs.observe(document.body, { childList: true });
|
| 409 |
+
setTimeout(cleanHF, 300);
|
| 410 |
+
setTimeout(cleanHF, 1000);
|
| 411 |
+
setTimeout(cleanHF, 3000);
|
| 412 |
})();
|
| 413 |
</script>
|
| 414 |
<canvas id="gameCanvas"></canvas>
|