ADP and Background Images

Various discussions related to Adblock Plus development

ADP and Background Images

Postby rodrogue » Fri Dec 18, 2015 7:59 pm

I was looking through the source code trying to understand how it works - I'm just not a javascript person.

How does ADP determine which HTML entities actually have a valid background property?

<body background=<url>> = Valid
<span background=<url>> = Not Valid

I seen how it determines the type options $images, $media and what it looks for. Just not sure how it determines which HTML elements the background is valid on.
rodrogue
 
Posts: 4
Joined: Thu Nov 19, 2015 9:06 pm

Re: ADP and Background Images

Postby mapx » Fri Dec 18, 2015 8:58 pm

Do you have some real example / issue ?
User avatar
mapx
 
Posts: 21947
Joined: Thu Jan 06, 2011 3:01 pm

Re: ADP and Background Images

Postby rodrogue » Fri Dec 18, 2015 9:34 pm

I don't have an issue, I'm just trying to understand how it magically knows all elements that have a background element.

For instance I'm looking at the include.preload.js for chrome.

I can see see how it's matching the type options

Code: Select all
var typeMap = {
  "img": "IMAGE",
  "input": "IMAGE",
  "picture": "IMAGE",
  "audio": "MEDIA",
  "video": "MEDIA",
  "frame": "SUBDOCUMENT",
  "iframe": "SUBDOCUMENT",
  "object": "OBJECT",
  "embed": "OBJECT"
};


Then I can see where it's looking for the URLS based on the element


Code: Select all
function getURLsFromElement(element)
{
  var urls;
  switch (element.localName)
  {
    case "object":
      urls = getURLsFromObjectElement(element);
      break;

    case "video":
    case "audio":
    case "picture":
      urls = getURLsFromMediaElement(element);
      break;

    default:
      urls = getURLsFromAttributes(element);
      break;
  }


I can follow the logic a little, but when it comes to backgrounds - I don't see any type of mappings - How does it know that <body> <table> etc are valid tags? and that <span> isn't - I don't see where it's searching to find the background element url, it works great and finds them, I just don't know how..
rodrogue
 
Posts: 4
Joined: Thu Nov 19, 2015 9:06 pm

Re: ADP and Background Images

Postby lewisje » Sat Dec 19, 2015 5:21 am

I believe that the webRequest API tells ABP what kind of request it was; ABP does not scan the HTML of pages that it blocks ads on to determine what and how to block them.

For Firefox, nsIContentPolicy is similar.
There's a buzzin' in my brain I really can't explain; I think about it before they make me go to bed.
lewisje
 
Posts: 2744
Joined: Mon Jun 14, 2010 12:07 pm


Return to Adblock Plus development

Who is online

Users browsing this forum: No registered users and 2 guests