MediaWiki:Reddit Widget.js

/* ================================================== */ /* ====  Reddit Widget                          ==== */ /* ================================================== */ $(document).ready(function {   var enableWidget = document.getElementById("reddit-LN");    if (enableWidget)    {        // Reddit cannot be loaded through appending script tag as homepage has scripts that interferes with reddit script        var redditWidget = document.createElement("iframe");        redditWidget.width = "100%";        enableWidget.appendChild(redditWidget);        // Add the script         redditWidget.contentWindow.document.write("       ");        // Readjust height based on how much content reddit widget has        var tryReadjust = setInterval(function {           // Take contents of iframe out and put it on page (lol) // Otherwise page keeps loading (for some reason), and cannot be clicked because Reddit // set X-Frame-options to SAMEORIGIN var t = redditWidget.contentDocument.children; t = t[0].getElementsByClassName("rembeddit")[0]; if (t) {               // Have to wait until element exists before taking it out document.getElementById("reddit-LN").appendChild(t); redditWidget.remove; clearInterval(tryReadjust); }       }, 1000);    } });