MediaWiki:Common.js: Difference between revisions
No edit summary Tags: Manual revert Mobile edit Mobile web edit Advanced mobile edit |
No edit summary Tags: Mobile edit Mobile web edit Advanced mobile edit |
||
Line 9: | Line 9: | ||
document.head.appendChild(script); | 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); | |||
}); | |||
}); |
Latest revision as of 19:53, 15 January 2025
// 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); }); });