File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed
Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change 33// blog-post ๋ด์ AdSense in feed ์ฝ๋ ์ฝ์
.
44function insertAdInRandomLocation ( ) {
55 let adCode =
6+ '<li class="post-preview" id="ad-container">' +
7+ '<article>' +
8+ '<h1> ์ ์๋ ๊น..<\/h1>' +
69 '<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1101850893094860" crossorigin="anonymous"><\/script>' +
7- '<ins class="adsbygoogle" style="display:block;" data-ad-format="fluid" data-ad-layout-key="-d2-a+73-vo+fv" data-ad-client="ca-pub-1101850893094860" data-ad-slot="2708788380"><\/ins>' +
8- '<script> (adsbygoogle = window.adsbygoogle || []).push({}); <\/script>' ;
9-
10- // var adElement = document.createElement("div");
11- // adElement.innerHTML = adCode;
10+ '<ins class="adsbygoogle" style="display:block" data-ad-format="fluid" data-ad-layout-key="-d2-a+73-vo+fv" data-ad-client="ca-pub-1101850893094860" data-ad-slot="2708788380"><\/ins>' +
11+ '<script> (adsbygoogle = window.adsbygoogle || []).push({}); <\/script>' +
12+ '<\/article>' +
13+ '<\/li>' ;
1214
1315 var elements = document . querySelectorAll ( '.post-preview' ) ;
14-
1516 var randomIndex = Math . floor ( Math . random ( ) * elements . length ) ;
1617 var randomElement = elements [ randomIndex ] ;
18+
1719
18- // randomElement.insertBefore(adElement, randomElement.firstChild);
1920 randomElement . insertAdjacentHTML ( 'beforebegin' , adCode ) ;
20-
21+
22+ let selectedElementHeight = randomElement . clientHeight ;
23+ var adContainer = document . getElementById ( 'ad-container' ) ;
24+ adContainer . style . height = selectedElementHeight + 'px' ;
2125}
2226
2327document . addEventListener ( "DOMContentLoaded" , insertAdInRandomLocation ) ;
You canโt perform that action at this time.
0 commit comments