Skip to content

Instantly share code, notes, and snippets.

@JamoCA
Last active December 15, 2023 03:13
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save JamoCA/99505f3dad38f23d3dcaa73a4eb6d030 to your computer and use it in GitHub Desktop.
Save JamoCA/99505f3dad38f23d3dcaa73a4eb6d030 to your computer and use it in GitHub Desktop.
Greasemonkey script to remove Google Ads
// ==UserScript==
// @name GoogleNoAds
// @namespace gist.github.com/JamoCA/99505f3dad38f23d3dcaa73a4eb6d030
// @description Remove inline ads from Google
// @include https://www.google.com/
// @version 1.1
// @grant none
// ==/UserScript==
// ==/UserScript==
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
$(document).ajaxComplete(function() {
$('.ads-ad').remove();
});
setInterval(function(){
$('.ads-ad').remove();
}, 1000);
@IgorKvasn
Copy link

IgorKvasn commented Jan 17, 2020

(function() {
    'use strict';

    document.querySelectorAll('.ads-ad').forEach(function(e){
        e.remove();
    });
})();

@TimmyP777
Copy link

Can this be updated?

@JamoCA
Copy link
Author

JamoCA commented May 20, 2022

I try to avoid using Google as much as possible these days. I believe they started obfuscating the class names that they use. (I've also switched to https://www.tampermonkey.net/ )

As a workaround, I've started using Stylus to write CSS override rules. This utility make some websites more tolerable by hiding/showing, moving and replacing content.
https://add0n.com/stylus.html

@khaslu
Copy link

khaslu commented Aug 3, 2022

// ==UserScript==
// @name Remove AD Google
// @namespace http://tampermonkey.net/
// @Version 0.1
// @description Remove AD Google
// @author Lucas Mota Vieira
// @match https://www.google.com/*
// @ICON https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant none
// ==/UserScript==

(function() {
'use strict';

function ready(callback){
    // in case the document is already rendered
    if (document.readyState!='loading') callback();
    // modern browsers
    else if (document.addEventListener) document.addEventListener('DOMContentLoaded', callback);
    // IE <= 8
    else document.attachEvent('onreadystatechange', function(){
        if (document.readyState=='complete') callback();
    });
}

ready(function(){
    document.querySelectorAll('#tads').forEach(function(e) {
        e.remove();
    })
});

})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment