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

℡╲_俬逩灬. 提交于 2019-12-03 17:08:01

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.

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