Skip to content

Instantly share code, notes, and snippets.

@ajs256
Last active December 16, 2022 00:27
Show Gist options
  • Save ajs256/9ffbd460316f4d228b8911de7b9956c1 to your computer and use it in GitHub Desktop.
Save ajs256/9ffbd460316f4d228b8911de7b9956c1 to your computer and use it in GitHub Desktop.
uBlock Origin 3rd-party iframe blocker

This is a simple filter for uBlock Origin to require any third-party iframes to be clicked to load. Here's a screenshot from the MDN page on the iframe element: image

This only works with uBlock Origin - other blockers might not have the click2load.html resource.

Paste the filter code below into your "My filters" settings to use it.

*$third-party,subdocument,redirect=click2load.html

Explanation:

  • * - run this filter on every page
  • $ - separates the URL from the options
  • third-party - only match if it's "third-party" (the base domain is different from the root document)
  • subdocument - only match on embedded pages, such as iframes and frames
  • redirect=click2load.html - redirect anything that matches to uBlock Origin's

To allow frames on a specific site, use the code below, replacing example.com with the site you want to allow.

@@||*$subdocument,domain=example.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment