@@ -74,26 +74,41 @@ const sharedCss = ` * { box-sizing: border-box; }
7474 .demo-badge { display: inline-block; margin-top: 6px; font-size: 0.78em; color: #a0c8a8; letter-spacing: 1px; }
7575 .demo-badge a { color: #94c3e8; }
7676 .daily-badge { display: inline-block; margin-left: 8px; font-size: 0.65em; color: #a0d0a8; letter-spacing: 2px; vertical-align: middle; font-weight: normal; }
77- .ad-slot { position: relative; margin: 24px 0; min-height: 90px; display: flex; align-items: center; justify-content: center; background: #11161e; border: 1px dashed #2a3540; border-radius: 4px; padding: 6px; }
77+ .ad-slot { position: relative; width: 100%; margin: 24px 0; min-height: 90px; display: block; background: #11161e; border: 1px dashed #2a3540; border-radius: 4px; padding: 6px; overflow: hidden ; }
7878 .ad-slot::before { content: 'Advertisement'; position: absolute; top: -18px; left: 50%; transform: translateX(-50%); color: #5a6874; font-size: 0.65em; letter-spacing: 3px; pointer-events: none; }
79- .ad-slot ins { display: block !important; }
79+ .ad-slot ins.adsbygoogle { display: block !important; width: 100% !important; min-height: 90px ; }
8080 footer { margin-top: 60px; text-align: center; color: #5a6874; font-size: 0.78em; letter-spacing: 2px; line-height: 1.8; }
8181 footer a { color: #8098a8; text-decoration: none; }
8282 footer a:hover { color: #d8d0c0; }
8383 .disclosure { color: #5a6874; font-size: 0.72em; max-width: 700px; margin: 30px auto 0; line-height: 1.6; letter-spacing: 0.5px; font-style: italic; }` ;
8484
85- function adUnit ( slot , format , style ) {
85+ function adUnit ( slot , style ) {
8686 return ` <div class="ad-slot"${ style ? ` style="${ style } "` : '' } >
8787 <ins class="adsbygoogle"
88- style="display:block${ format === 'horizontal' ? '' : ';text-align:center' } "
88+ style="display:block"
8989 data-ad-client="${ PUB } "
9090 data-ad-slot="${ slot } "
91- data-ad-format="${ format } "
91+ data-ad-format="auto "
9292 data-full-width-responsive="true"></ins>
93- </div>
94- <script>(adsbygoogle = window.adsbygoogle || []).push({});</script>` ;
93+ </div>` ;
9594}
9695
96+ const adInitScript = `<script>
97+ (function () {
98+ function fillAds() {
99+ var slots = document.querySelectorAll('ins.adsbygoogle');
100+ for (var i = 0; i < slots.length; i++) {
101+ (adsbygoogle = window.adsbygoogle || []).push({});
102+ }
103+ }
104+ if (document.readyState === 'loading') {
105+ document.addEventListener('DOMContentLoaded', function () { requestAnimationFrame(fillAds); });
106+ } else {
107+ requestAnimationFrame(fillAds);
108+ }
109+ })();
110+ </script>` ;
111+
97112const dailyGames = games . filter ( g => g . daily ) ;
98113const dailyStrip = dailyGames . length
99114 ? ` <div class="daily-strip">
@@ -139,15 +154,15 @@ ${sharedCss}
139154 <a href="privacy.html">Privacy</a>
140155 </nav>
141156
142- ${ adUnit ( '0000000000' , 'horizontal' ) }
157+ ${ adUnit ( '0000000000' ) }
143158
144159${ dailyStrip }
145160${ section ( 'puzzles' , { highlightPuzzles : true } ) }
146- ${ adUnit ( '0000000000' , 'auto' , ' margin:32px 0') }
161+ ${ adUnit ( '0000000000' , 'margin:32px 0' ) }
147162${ section ( 'board' ) }
148163${ section ( 'sims' ) }
149164
150- ${ adUnit ( '0000000000' , 'auto' , ' margin:32px 0') }
165+ ${ adUnit ( '0000000000' , 'margin:32px 0' ) }
151166
152167 <p class="disclosure">
153168 This page is supported by Google AdSense advertisements. Ads help keep the games free.
@@ -165,6 +180,7 @@ ${adUnit('0000000000', 'auto', 'margin:32px 0')}
165180 <a href="https://github.com/mf4633/board-gaming">github.com/mf4633/board-gaming</a>
166181 </footer>
167182</div>
183+ ${ adInitScript }
168184<script src="/analytics.js"></script>
169185<script src="/nav.js" defer></script>
170186</body>
0 commit comments