Has anyone figured out how to add a simple adsense ad in Rocket chat?
It seems that it is not a very straight forward task since it uses meteor.js. I have tried adding the following code in home.js without any luck.
Template.home.onRendered(function() {
$(document).ready(function() {
var script = document.createElement("script");
script.type="text/javascript";
script.src = "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js";
$(".ad-wrapper").append(script);
var ads, adsbygoogle;
ads = '<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3*****4978" data-ad-slot="2*****448" data-ad-format="auto" data-full-width-responsive="true"></ins>';
$('.ad-wrapper').html(ads);
return (adsbygoogle = window.adsbygoogle || []).push({});
});
});
I’ve also tried this and added the “ad” object in home.html
ad() {
$.getScript("//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js", function() {
var ads, adsbygoogle;
ads = '<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3*****4978" data-ad-slot="2*****448" data-ad-format="auto" data-full-width-responsive="true"></ins>';
$('.ad-wrapper').html(ads);
return (adsbygoogle = window.adsbygoogle || []).push({});
});
},