「MediaWiki:Sitenotice」の版間の差分

提供:畜産用語辞典
編集の要約なし
タグ: 手動差し戻し
編集の要約なし
タグ: 差し戻し済み
1行目: 1行目:
<htmlet nocache="yes">google_adsense</htmlet>
<html>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TQ4D377"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<style>
.sitenotice_ad_responsive { width: 320px; height: 100px; }
ins.adsbygoogle { background: transparent; text-decoration: none; }
@media(min-width: 500px) { .sitenotice_ad_responsive { width: 468px; height: 60px; } }
@media(min-width: 800px) { .sitenotice_ad_responsive { width: 728px; height: 90px; } }
</style>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4788994154907361"
    crossorigin="anonymous"></script>
<script>
document.addEventListener('DOMContentLoaded', function(event) {
  let params = {
    id: "adsenseSidebar",
    className: "adsbygoogle",
    cssText: "display:block; margin-top: 1em;",
    adSlot: "2741942082",
    adFormat: "auto",
    responsive: "true"
  };
  if(document.querySelector("#vector-main-menu")) {
    insertAdSense("#vector-main-menu", params, "_append");
  } else {
    insertAdSense("#mw-panel", params, "_append");
  }
  params = {
    id: "adsenseBottom",
    className: "adsbygoogle",
    cssText: "display:block; margin: 0 auto;",
    adSlot: "6453407645",
    adFormat: "auto",
    responsive: "true"
  };
  insertAdSense("#bodyContent", params, "_append");
  params = {
    id: "adsenseTop",
    className: "adsbygoogle sitenotice_ad_responsive",
    cssText: "display:block; margin: 0 auto; text-align: center;",
    adSlot: "1092610922"
  };
  insertAdSense("#content", params, "_prepend");
  document.querySelectorAll('.adsbygoogle').forEach(function(element) {
    try {
      (adsbygoogle = window.adsbygoogle || []).push({});
    } catch (error) {
      console.error(error);
    }
  });
});
 
function insertAdSense(id, params, method) {
  let panel = document.querySelector(id);
  if (panel) {
    let child = createAdSenseElement(params);
    let element = document.createElement("p");
    element._html(child);
    panel[method](element);
  }
}
 
function createAdSenseElement(params) {
  const ins = document.createElement("ins");
  ins.id = params.id;
  ins.className = params.className;
  ins.style.cssText = params.cssText;
  ins.setAttribute('data-ad-client', 'ca-pub-4788994154907361');
  ins.setAttribute('data-ad-slot', params.adSlot);
  if (params.adFormat) {
    ins.setAttribute('data-ad-format', params.adFormat);
  }
  if (params.responsive) {
    ins.setAttribute('data-full-width-responsive', params.responsive);
  }
  return ins;
}
 
Element.prototype._html = function (element) {
  if (typeof element == 'string') {
    this.innerHTML = element;
  } else {
    this.innerHTML = element.outerHTML;
  }
}
 
Element.prototype._before = function (element) {
  let tmp = document.createElement("span");
  tmp._html(element);
  this.parentElement.insertBefore(tmp.firstChild, this);
}
 
Element.prototype._after = function (element) {
  let tmp = document.createElement("span");
  tmp._html(element);
  this.parentElement.insertBefore(tmp.firstChild, this.nextSibling);
}
 
Element.prototype._append = function (element) {
  let tmp = document.createElement("span");
  tmp._html(element);
  this.appendChild(tmp.firstChild);
}
 
Element.prototype._prepend = function (element) {
  let tmp = document.createElement("span");
  tmp._html(element);
  this.insertBefore(tmp.firstChild, this.firstChild);
}
</script>
</html>

2023年10月23日 (月) 21:17時点における版