Greasemonkey to hide an image?

Discussion in 'Other Languages' started by Scorpion Ghost, Feb 13, 2015.

  1. Scorpion Ghost

    Scorpion Ghost Supreme Member

    Joined:
    Mar 22, 2013
    Messages:
    1,341
    Likes Received:
    378
    Occupation:
    Internet!
    Location:
    On the Interwebz
    I hope I'm posting in the right section.

    So I need to make Greasemonkey hide an image.

    I've already set it to take effect on the page I want it to hide an image on, but I can't get a code to work to actually hide the image.

    This is the image's HTML code:

    HTML:
    <img src="http://www.somesite.org/img/icon/something.png" alt="one" title="two" height="18px" width="50px">
    So I know this code works:

    HTML:
    $('a').each(function(){
       if($(this).css('background-image')=='url("http://www.something.org/img/icon/something.png")'){
           $(this).parent().remove();
       } 
    });
    I know that the part ".css('background-image')...." is what defines what needs to be hidden, but how do I put that image above there so that it'll work??

    Note: The image above (in the first HTML code) is NOT a background-image, that's why my solution doesn't work as it is.
     
    Last edited: Feb 13, 2015
  2. sockpuppet

    sockpuppet Junior Member

    Joined:
    Nov 7, 2011
    Messages:
    155
    Likes Received:
    145
    try this with the url of your image
    Code:
    $('img').each(function(){ 
        if ($(this).attr('src') == 'http://www.somesite.org/img/icon/something.png' ){
            $(this).remove(); 
        }
    });
    
     
    • Thanks Thanks x 1