1/** 2 * äºå¥ªæ¦ ãã¼ã¯ã¢ã¼ã èªåããªã¬ã¼ï¼å ¨ãã¼ã¸å ±éï¼ 3 * 4 * window.AUTO_DARK_BATTLE ã DarkModeBattleComposer ããæ³¨å ¥ããã¦ããå ´åã®ã¿åä½ããã 5 * 6 * window.AUTO_DARK_BATTLE = { 7 * lotteryId: number, 8 * startMs: number, // éå¬éå§æå» (ms epoch) 9 * endMs: number, // éå¬çµäºæå» (ms epoch) 10 * }; 11 * 12 * 仿§: 13 * - 対象ãã¼ã¸ (body.page-top / body.page-battle-lottery / body.page-lottery / body.page-coin-conversion) ã®ã¿ãã¼ã¯å 14 * - page-battle-lottery ã¯å¸¸æãã¼ã¯ã®ãã turnOff ããªã 15 * - éå¬ 10 ç§å (= floor((startMs - now)/1000) <= 10) ã§ ON 16 * - éå¬çµäº / 30 åçµé ã§ OFFï¼ãã§ã¤ã«ã»ã¼ãï¼ 17 * - 売ãåã峿 OFF 㯠lottery_page å´ã® MutationObserver ãæ å½ 18 * - is-active-dark-battle ã¯ã©ã¹ãè©²å½ lottery_id ãæã¤è¦ç´ ã«ä»ä¸ï¼è¹è²ãã¼ãã¼ç¨ï¼ 19 */ 20(function () { 21 var battle = window.AUTO_DARK_BATTLE; 22 if (!battle || typeof battle.startMs !== 'number' || typeof battle.endMs !== 'number') { 23 return; 24 } 25 26 var DARK_DISPLAY_SEC = 10; 27 var DARK_MAX_MS = 30 * 60 * 1000; 28 var html = document.documentElement; 29 var darkOffTimer = null; 30 31 function isTargetPage() { 32 var body = document.body; 33 if (!body) return false; 34 return body.classList.contains('page-top') 35 || body.classList.contains('page-battle-lottery') 36 || body.classList.contains('page-lottery') 37 || body.classList.contains('page-coin-conversion'); 38 } 39 40 function isPermanentDarkPage() { 41 var body = document.body; 42 return body && body.classList.contains('page-battle-lottery'); 43 } 44 45 function turnOn() { 46 if (!isTargetPage()) return; 47 if (html.classList.contains('dark-mode-on')) return; 48 html.classList.add('dark-mode-on'); 49 if (isPermanentDarkPage()) return; 50 if (darkOffTimer) clearTimeout(darkOffTimer); 51 darkOffTimer = setTimeout(turnOff, DARK_MAX_MS); 52 } 53 54 function turnOff() { 55 // battle ç³»ãã¼ã¯ããªã¬ã¼ã管è½ãã対象ãã¼ã¸ä»¥å¤ã§ã¯å¥å¥ªããªã. 56 // ä¾: page-auction 㯠auction-room.js ãç¬ç«ã§ dark-mode-on ã管çããããã 57 // battle çµäºæã«ããã§å¥å¥ªããã¨æå³ããã©ã¤ãã¢ã¼ãã«æ»ã£ã¦ãã¾ã. 58 // docs/features/auction-dark-mode-low-remaining/spec.md åç § 59 if (!isTargetPage()) return; 60 if (isPermanentDarkPage()) return; 61 html.classList.remove('dark-mode-on'); 62 if (darkOffTimer) { clearTimeout(darkOffTimer); darkOffTimer = null; } 63 } 64 65 function whenBodyReady(fn) { 66 if (document.body) { fn(); return; } 67 document.addEventListener('DOMContentLoaded', fn, { once: true }); 68 } 69 70 // éå¬ä¸ã® battle ã«å¯¾å¿ãã DOM è¦ç´ ï¼ã«ã¼ã / ãµã ã / ã«ã¬ã³ãã¼ï¼ã« 71 // is-active-dark-battle ã¯ã©ã¹ãä»ä¸ãããCSS å´ã§ãç¾å¨éå¬ä¸ã® battle ã®ã¿ãã« 72 // è¹è²ãã¼ãã¼ãå½ã¦ãããã®ãã¼ã«ã¼ã 73 function markActiveBattleNodes() { 74 var sel = '[data-lottery-id="' + battle.lotteryId + '"]'; 75 document.querySelectorAll(sel).forEach(function (el) { 76 el.classList.add('is-active-dark-battle'); 77 }); 78 } 79 whenBodyReady(markActiveBattleNodes); 80 81 function shouldBeDark(t) { 82 if (t >= battle.startMs) return true; 83 var displaySec = Math.floor((battle.startMs - t) / 1000); 84 return displaySec <= DARK_DISPLAY_SEC; 85 } 86 87 var now = Date.now(); 88 if (battle.endMs && now >= battle.endMs) return; // æ¢ã«çµäº 89 90 if (shouldBeDark(now)) { 91 whenBodyReady(turnOn); 92 } 93 94 if (battle.endMs) { 95 setTimeout(turnOff, Math.max(0, battle.endMs - now)); 96 } 97 98 // CountdownSyncClock ã« subscribe ãã¦ãã«ã¦ã³ããã¦ã³è¡¨ç¤ºã¨åãã¬ã¼ã ã§ãã¼ã¯åå¤å® 99 if (window.CountdownSyncClock) { 100 var darkTick = window.CountdownSyncClock.subscribe(function (t) { 101 if (battle.endMs && t >= battle.endMs) { 102 window.CountdownSyncClock.unsubscribe(darkTick); 103 return; 104 } 105 if (shouldBeDark(t) && !html.classList.contains('dark-mode-on')) { 106 whenBodyReady(turnOn); 107 } 108 }); 109 } 110})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.