Search code examples
javascripthtmlcsstampermonkey

How do I edit live css using tampermonkey without using Amino: Live CSS Editor


I wondering if it's possible to create a Tampermonkey script with javascript that will find and replace an existing html or css element that already exists.

In my case I want to add this to the css element at the domain google.com to change display to none:

    #tvcap {
        display: none;
    }

This prevents me from seeing annoying ads. I use Pi-hole, so at this point they are just taking up space on my screen.

I installed Amino: Live CSS Editor chrome extension and it's working great. I only have to use these 3 lines of code but I'd preferably want to use Tampermonkey with a JS script.

example:

Amino: Live CSS Editor

Before:

enter image description here

After:

enter image description here


Solution

  • This works.

    // ==UserScript==
    // @name         Block google ads
    // @namespace    http://tampermonkey.net/
    // @version      0.1
    // @description  try to take over the world!
    // @author       You, credit: https://stackoverflow.com/users/5053475/daniele-rugginenti
    // @match        https://*/*
    // @grant        none
    // ==/UserScript==
    
    
    
    (function() {
        'use strict';
    
        document.getElementById("tvcap").style.display = "none";
    })();