I am having a bunch of problems with running ads on Discourse site on https://howtodiscuss.com.
- Many uncaught DOM Exception errors, just goto any topic pages in incognio mode u will see them https://howtodiscuss.com/t/profit/7022
-
And other error is when i navigate to a new topic from an old topic page, i get this warning in console, a google Vignette ad is shown but due to this warning the ad disappears and page navigates, hence user is never able to click Google Vignette Interstitial ads that appear between page loads/navigations.
Deprecation notice: Removing all event listeners at once is deprecated, please remove each listener individually. https://howtodiscuss.com/t/how-many-ounces-is-a-1-4-cup/18390
- I am also trying to show a fixed sticky google ad on right side bar of single topic page, using this code,
Javascript code to inset sticky fixed ad on topic side bar, need to make it work with ToC too
<!-- plugin code to show fixed ad-->
<script type = "text/discourse-plugin"
version = "0.8" >
var friends_retries = 0;
var friends_timeout;
api.decorateWidget('topic-timeline-container:before', helper => {
return helper.h('div.side-block', [
helper.rawHtml('<div id="friends"></div>'),
]);
});
api.onPageChange(() => {
if (window.location.href.indexOf("/t/") > -1) {
console.log('page changed - topic');
friends_retries = 0;
window.setTimeout(loadFriends, 100);
} else {
//console.log( 'page changed - not topic');
}
});
function loadFriends() {
if (!document.getElementById('friends')) {
//var timer;
friends_retries++;
if (friends_retries < 10) {
//console.log('timeout rescheduled, try ' + friends_retries);
window.setTimeout(loadFriends, 100);
} else {
clearTimeout(friends_timeout);
// window.clearTimeout(loadFriends);
console.log('timeout cleared, gave up');
// loadFriends();
}
} else {
var bHTML = ' <!-- Topic side bar timeline HTD --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-7087907313091932" data-ad-slot="5067761793" data-ad-format="auto" data-full-width-responsive="true"></ins>';
// var bHTML = '<img src="https://via.placeholder.com/300x250?text=300x250+MPU" alt="Girl in a jacket">';
$("#friends").html(bHTML);
}
}
</script>
<!-- plugin code to show fixed ad-->
Here is its CSS code:
/*for fixed ad*/
/* timeline layout fix 2.6.0.beta5 */
@media screen and (min-width: 925px) {
.container.posts .topic-navigation {
margin-left: 7em;
}
}
#friends {
display:block;
//width:300px;
height:150px;
margin-left:-90px;
margin-top:-25px;
margin-bottom:90px;
}
/*for fixed ad*/
Sometimes this code works, but it does not work on the page where ToC appears, e.g not working on https://howtodiscuss.com/t/how-many-grams-in-a-quarter-ounce/12300
Can someone correct my mistake in my code so that it can show on ToC pages too?
-
I have also noticed another bug in my code and overall discourse ad plugin code, when i m navigating from one page to another, my adsense ad code is never refreshed and never reloaded, so it doesn’t trigger any ad impression. May be because Discourse does not fully reload enitre page when we navigate. I want ads to be refreshed and full page to be reloaded from any link navigation, how can i fix this?
-
I am also getting many of these frame-src errors on my site, https://howtodiscuss.com/t/how-mouthwash-rinse-become-a-necessary-step-in-oral-hygiene/30631
Refused to frame 'https://pagead2.googlesyndication.com/' because it violates the following Content Security Policy directive: "frame-src cm.g.doubleclick.net googleads.g.doubleclick.net www.google.com accounts.google.com pagead2.googlesyndication.com/pagead/s/cookie_push.html gmsg: https://tpc.googlesyndication.com/sadbundle/$csp=er3$/1522577804659956528/index.html".
This is how my CSP settings look like,
But i dont know how to whitelist Google ads iframe requests? I also tried this code, but its not working well, i m still seeing the above frame-src errors,
if i add values next to frame-src in meta, it gives me error that we cannot use frame-src in meta tag.
<!--<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' http://* 'unsafe-inline'; frame-src ; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'" />-->
It will be huge help if anyone can help me solve my problems,
I am even getting such errors on my homepage, https://howtodiscuss.com/ (to replicate errors, open the page in incognito, or use vpn or just refresh few times or navigate to other pages, you will find the errors in JS console, and will also see the Google vignette dismissing without giving chance to user to click the ad)
Hope someone can help.
My site is on cloudflare, i m on latest discourse version 2.6.0.beta6, i have updated everything all plugins and also have rebuilt docker just now. still i see these errors.