MediaWiki:Common.js

From Earthpedia
Revision as of 19:53, 15 January 2025 by Nishanttaliyan07 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// Google AdSense Code for automatic ads
if (window.adsbygoogle) {
    (adsbygoogle = window.adsbygoogle || []).push({});
} else {
    var script = document.createElement('script');
    script.async = true;
    script.src = "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8088287166824436";
    script.crossOrigin = "anonymous";
    document.head.appendChild(script);
}



$(document).ready(function() {
    var wikitextContent = '{{AdSense}}';  // This is the wikitext template you want to insert
    var renderedHTML = mw.loader.using('mediawiki.widget').done(function() {
        // Use mw.html to render the wikitext as HTML
        var rendered = mw.html.escape(wikitextContent); // Escape wikitext content
        
        // Insert rendered HTML into a container element (e.g., a div)
        $('#ad-container').html(rendered);
    });
});