Spaces:
Running
Running
Update index.html
Browse files- index.html +31 -21
index.html
CHANGED
|
@@ -941,6 +941,12 @@
|
|
| 941 |
|
| 942 |
// --- Cheat Codes ---
|
| 943 |
document.addEventListener('keydown', e => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 944 |
cheatCodeBuffer += e.key;
|
| 945 |
// 增加緩衝區長度以容納 [scoreboard]
|
| 946 |
if (cheatCodeBuffer.length > 12) {
|
|
@@ -1159,7 +1165,7 @@
|
|
| 1159 |
goToScreen(1);
|
| 1160 |
}
|
| 1161 |
|
| 1162 |
-
|
| 1163 |
async function initializeFirebase() {
|
| 1164 |
if (isFirebaseReady) return;
|
| 1165 |
|
|
@@ -1171,25 +1177,17 @@
|
|
| 1171 |
|
| 1172 |
try {
|
| 1173 |
// --- NEW: Firebase Config Logic ---
|
| 1174 |
-
|
| 1175 |
-
|
| 1176 |
-
|
| 1177 |
-
|
| 1178 |
-
|
| 1179 |
-
|
| 1180 |
-
|
| 1181 |
-
|
| 1182 |
-
|
| 1183 |
-
|
| 1184 |
-
|
| 1185 |
-
apiKey: "AIzaSyAiG08OIPLrXA5CqsSl-rR0Z1FvhFog9cU",
|
| 1186 |
-
authDomain: "ai-adventure-scoreboard.firebaseapp.com",
|
| 1187 |
-
projectId: "ai-adventure-scoreboard",
|
| 1188 |
-
storageBucket: "ai-adventure-scoreboard.firebasestorage.app",
|
| 1189 |
-
messagingSenderId: "814089769337",
|
| 1190 |
-
appId: "1:814089769337:web:09d46c9e623d0db95f1fa8"
|
| 1191 |
-
};
|
| 1192 |
-
}
|
| 1193 |
// --- END NEW ---
|
| 1194 |
|
| 1195 |
if (!firebaseConfig.apiKey) {
|
|
@@ -1203,11 +1201,22 @@
|
|
| 1203 |
fbSDK.setLogLevel('Debug'); // 方便除錯
|
| 1204 |
|
| 1205 |
// 執行匿名登入
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1206 |
if (typeof __initial_auth_token !== 'undefined') {
|
| 1207 |
await fbSDK.signInWithCustomToken(auth, __initial_auth_token);
|
| 1208 |
} else {
|
| 1209 |
await fbSDK.signInAnonymously(auth);
|
| 1210 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1211 |
|
| 1212 |
// 取得並儲存這個(匿名)使用者的唯一 ID
|
| 1213 |
userId = auth.currentUser ? auth.currentUser.uid : crypto.randomUUID();
|
|
@@ -3233,4 +3242,5 @@
|
|
| 3233 |
|
| 3234 |
</script>
|
| 3235 |
</body>
|
| 3236 |
-
</html>
|
|
|
|
|
|
| 941 |
|
| 942 |
// --- Cheat Codes ---
|
| 943 |
document.addEventListener('keydown', e => {
|
| 944 |
+
// NEW FIX: 僅將單一、可列印的字元添加到緩衝區
|
| 945 |
+
// 這能防止 "Shift", "Control", "Backspace" 等鍵污染密碼
|
| 946 |
+
if (e.key.length > 1) {
|
| 947 |
+
return; // 忽略 "Shift", "Control" 等非字元鍵
|
| 948 |
+
}
|
| 949 |
+
|
| 950 |
cheatCodeBuffer += e.key;
|
| 951 |
// 增加緩衝區長度以容納 [scoreboard]
|
| 952 |
if (cheatCodeBuffer.length > 12) {
|
|
|
|
| 1165 |
goToScreen(1);
|
| 1166 |
}
|
| 1167 |
|
| 1168 |
+
<!-- --- NEW: Firebase Init Function ---
|
| 1169 |
async function initializeFirebase() {
|
| 1170 |
if (isFirebaseReady) return;
|
| 1171 |
|
|
|
|
| 1177 |
|
| 1178 |
try {
|
| 1179 |
// --- NEW: Firebase Config Logic ---
|
| 1180 |
+
// 依照您的要求,直接使用您提供的硬編碼(hard-coded)設定
|
| 1181 |
+
// 移除了所有對 __firebase_config 的檢查
|
| 1182 |
+
console.log("Using hard-coded Firebase config directly.");
|
| 1183 |
+
const firebaseConfig = {
|
| 1184 |
+
apiKey: "AIzaSyAiG08OIPLrXA5CqsSl-rR0Z1FvhFog9cU",
|
| 1185 |
+
authDomain: "ai-adventure-scoreboard.firebaseapp.com",
|
| 1186 |
+
projectId: "ai-adventure-scoreboard",
|
| 1187 |
+
storageBucket: "ai-adventure-scoreboard.firebasestorage.app",
|
| 1188 |
+
messagingSenderId: "814089769337",
|
| 1189 |
+
appId: "1:814089769337:web:09d46c9e623d0db95f1fa8"
|
| 1190 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1191 |
// --- END NEW ---
|
| 1192 |
|
| 1193 |
if (!firebaseConfig.apiKey) {
|
|
|
|
| 1201 |
fbSDK.setLogLevel('Debug'); // 方便除錯
|
| 1202 |
|
| 1203 |
// 執行匿名登入
|
| 1204 |
+
// --- FIX: Force anonymous sign-in ---
|
| 1205 |
+
// Since we are using a hard-coded Firebase project,
|
| 1206 |
+
// we must ignore any environment-provided custom tokens (like __initial_auth_token),
|
| 1207 |
+
// as they will not match this project and will cause an auth/custom-token-mismatch error.
|
| 1208 |
+
// We will always sign in anonymously.
|
| 1209 |
+
|
| 1210 |
+
/*
|
| 1211 |
if (typeof __initial_auth_token !== 'undefined') {
|
| 1212 |
await fbSDK.signInWithCustomToken(auth, __initial_auth_token);
|
| 1213 |
} else {
|
| 1214 |
await fbSDK.signInAnonymously(auth);
|
| 1215 |
}
|
| 1216 |
+
*/
|
| 1217 |
+
await fbSDK.signInAnonymously(auth);
|
| 1218 |
+
// --- END FIX ---
|
| 1219 |
+
|
| 1220 |
|
| 1221 |
// 取得並儲存這個(匿名)使用者的唯一 ID
|
| 1222 |
userId = auth.currentUser ? auth.currentUser.uid : crypto.randomUUID();
|
|
|
|
| 3242 |
|
| 3243 |
</script>
|
| 3244 |
</body>
|
| 3245 |
+
</html>
|
| 3246 |
+
|