How do I disable or hide the unwanted Disqus ads on my website?

不问归期 提交于 2019-12-05 03:33:47

问题


Imagine that one day, suddenly, random ads started appearing on your website...

Recently Disqus started forcing unwanted ads inside of the Disqus comments, displaying those nasty ads on your website(s) without your knowing. It seems that they only target the sites with "big enough" daily traffic or use some other arbitrary criteria, so the ads do not appear on all the websites, but only on relatively busy ones.

This way Disqus "forces" you to upgrade to the paid subscription plan - for the paid users these ads become optional (i.e. you can disable them in your Disqus admin panel).

What to do if you don't want to pay? How to disable these ads? Is there an easy, quick-fix solution for this?

At least until we have the time to switch to another commenting system.


回答1:


As of moment of writing, it seems that popular AdBlock browser extensions successfully block the ads. However, not all of your website visitors use adblock.

Here is a quick jQuery-based solution to hide the ads:

(function($){
    setInterval(() => {
        $.each($('iframe'), (arr,x) => {
            let src = $(x).attr('src');
            if (src && src.match(/(ads-iframe)|(disqusads)/gi)) {
                $(x).remove();
            }
        });
    }, 300);
})(jQuery);

Just insert it on your website after jQuery loads, on every page where the Disqus comments appear. The code checks periodically if there are Disqus ads present on your website and removes their container whatsover. You know, just in case if they'll try to re-appear.




回答2:


You can hide the ads iframes with CSS (note that what @DanielGale said is correct - this will be a cat and mouse game, your CSS selector will have to adapt):

iframe[src*="ads-iframe"] { display: none; }


来源:https://stackoverflow.com/questions/49131980/how-do-i-disable-or-hide-the-unwanted-disqus-ads-on-my-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!