Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collapse empty ad spaces (element hiding) #508

Merged
merged 13 commits into from
Oct 6, 2022

Conversation

dharb
Copy link
Collaborator

@dharb dharb commented Oct 2, 2022

Asana Tasks:

Description
This PR establishes a new config for the element hiding feature, which hides empty ad spaces where tracking ads were blocked. This will initially only be enabled in the macOS app, with other client support coming soon.

Config details

  • The exceptions key contains a list of hostnames where this element hiding is disabled
  • The settings key contains:
    • A list of global rules to be run on all sites
    • A list of domain-specific rules
    • A list of common ad labels (eg "advertisement")
  • Each rule consists of a CSS selector and a rule type that dictates what the script should do with matching elements. There are four rule types:
    • hide-empty - checks if element contains visible content, if not hides element
    • closest-empty - same as hide-empty, but recursively moves up the DOM tree hiding empty elements until it reaches a non-empty element
    • hide - hides matching elements without checking if empty first. Should only be used if we know for certain that matching elements always contain blocked ads
    • override - disables matching global rule, allows us to turn off a global rule on a specific domain if we find it's causing breakage there

@dharb dharb added the DO NOT MERGE Don't merge this branch unless directed label Oct 2, 2022
@dharb dharb removed the DO NOT MERGE Don't merge this branch unless directed label Oct 6, 2022
Copy link
Collaborator

@jonathanKingston jonathanKingston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thank you.

@jonathanKingston jonathanKingston merged commit ec43278 into main Oct 6, 2022
@jonathanKingston jonathanKingston deleted the dharb/element-hiding-test branch October 6, 2022 19:41
jonathanKingston pushed a commit to duckduckgo/content-scope-scripts that referenced this pull request Oct 6, 2022
This PR adds the element-hiding.js content script, which is injected into pages to hide empty ad spaces. This is similar functionality to what most ad blockers call 'cosmetic filtering' with one key caveat: we are only hiding spaces where ads didn't load due to blocked tracker requests. To accomplish this we use a heuristic to check each ad container selector for visible content, and only hide if no visible content (eg non-tracking ads) is found.

Initially this feature will only be enabled in the macOS app, with other client support to come as follow ups. This feature is v1, we will likely follow up with a more sophisticated approach in the near future.

This script functions based on Privacy Configuration rules so that coverage may be expanded remotely without requiring updates to this repo or clients.

To see this functionality in action, navigate to a site that has a large blank space at the top of the page where a tracking banner ad didn't load, and see that the empty space is hidden shortly after page load. A few example sites to check are bloomberg.com, cyclingtips.com, and fandom.com.

Asana link: https://app.asana.com/0/0/1203092629639220/f
Corresponding privacy config PR: duckduckgo/privacy-configuration#508
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants