Difference between revisions of "Template:Ads recomended"

From Enduro.team
Jump to: navigation, search
m
m
 
(32 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
<html>
 
<html>
 
<body>
 
<body>
<div class="adsrecomended">
 
 
<script>
 
<script>
var externalScript  = document.createElement("script");
 
externalScript.type  = "text/javascript";
 
externalScript.setAttribute('async','async');
 
externalScript.src = "//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9226951475373251";
 
document.getElementsByTagName('body')[0].appendChild(externalScript);
 
  
var ins   = document.createElement("ins");
+
if (window.matchMedia) {
ins.setAttribute('class','adsbygoogle');
+
   if(window.matchMedia('(prefers-color-scheme: dark)').matches){
ins.setAttribute('style','display:block;');/*add other styles if required*/
+
    var d1 = document.getElementById('adsrecomended');
ins.setAttribute('data-ad-client','9226951475373251');
+
    d1.insertAdjacentHTML('beforeend', '<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-9226951475373251" data-ad-slot="3158273233"></ins>');
ins.setAttribute('data-ad-slot','3159268773');
+
  } else {
ins.setAttribute('data-ad-format','autorelaxed');
+
    var d1 = document.getElementById('adsrecomended');
document.getElementsByTagName('body')[0].appendChild(ins);
+
    d1.insertAdjacentHTML('beforeend', '<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-9226951475373251" data-ad-slot="3159268773"></ins>');
 
+
  }
var inlineScript  = document.createElement("script");
+
} else {
inlineScript.type  = "text/javascript";
+
    var d1 = document.getElementById('adsrecomended');
inlineScript.text  = '(adsbygoogle = window.adsbygoogle || []).push({});'
+
    d1.insertAdjacentHTML('beforeend', '<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-9226951475373251" data-ad-slot="3159268773"></ins>');
document.getElementsByTagName('body')[0].appendChild(inlineScript);
+
}
 +
</script>
 +
<div class="adsrecomended" id="adsrecomended">
 +
<script>
 +
    (adsbygoogle = window.adsbygoogle || []).push({});
 
</script>
 
</script>
 
</div>
 
</div>

Latest revision as of 15:40, 22 July 2021