Blocking images that are not linked to a jpg

Posting here is no longer possible, please use the forum of a filter list project, such as EasyList
Locked
james

Blocking images that are not linked to a jpg

Post by james »

I was wondering if all (or most) images on a page (background images, unlinked images, and images linked to other than a jpg) can be blocked from a page, allowing only images that are linked to a jpg file. Thanks.
User avatar
Adblock Plus Fan
Posts: 1255
Joined: Sat Feb 24, 2007 11:08 am

Re: Blocking images that are not linked to a jpg

Post by Adblock Plus Fan »

james wrote:unlinked images, and images linked to other than a jpg
I imagine something like this should work:

Code: Select all

domain.com##IMG:not(A[href$=".jpg"] > IMG)
Except, it doesn't work ^^;;

Wladimir, or someone else, can you explain why this doesn't work?
Wladimir Palant

Post by Wladimir Palant »

:not() is very limited in what it can do. If you look at http://www.w3.org/TR/css3-selectors/#negation - only simple selectors can be used, meaning especially that no compound selectors are accepted here (mostly for performance reasons).

In userContent.css one could write something like this (note that the link isn't necessarily a direct parent of the image):

Code: Select all

@-moz-document domain(domain.com)
{
  img
  {
    display: none;
  }

  a[href $= ".jpg"] img
  {
    display: inline;
  }
}
You can also add this snippet of CSS code to Stylish. Adblock Plus isn't that flexible however.
Locked