uBlockOrigin / uBlock-issues

This is the community-maintained issue tracker for uBlock Origin
https://github.com/gorhill/uBlock
945 stars 81 forks source link

iframe with src="javascript:false;" defies filters #522

Closed jchook closed 5 years ago

jchook commented 5 years ago

Prerequisites

Description

A specific iframe with src="javascript:false;" will not go away!

unstoppable iframe

I have tried many combinations of filters and posted a support request on Reddit with no luck.

Examples of filters I have tried:

my.freshbooks.com##iframe
my.freshbooks.com##^iframe
my.freshbooks.com##^#zendesk-widget-iframe
my.freshbooks.com###zendesk-widget-iframe
my.freshbooks.com##.zendesk-widget-iframe
my.freshbooks.com##iframe#zendesk-widget-iframe
my.freshbooks.com##^iframe#zendesk-widget-iframe
my.freshbooks.com##iframe#zendesk-widget-iframe[src="javascript:false;"]
my.freshbooks.com##^iframe#zendesk-widget-iframe[src="javascript:false;"]
javascript:false;##iframe

The log appears to claim that uBO blocks the iframe.

I also tried enabling "Block 3rd party frames" with no success.

A specific URL where the issue occurs

https://my.freshbooks.com/#/login

Steps to Reproduce

  1. Visit Freshbooks Login
  2. Add a filter(s) for the iframe#zendesk-widget-iframe element
  3. Visit same page in a new window.
  4. See that iframe still exists in both source html and DOM.

Expected behavior:

I expect uBlockOrigin to remove the iframe from the HTML and from the DOM via various filters.

Actual behavior:

The iframe remains in both the HTML and the DOM.

Your environment

gorhill commented 5 years ago

See that iframe still exists in both source html and DOM.

As expected. Cosmetic filters do not remove elements from the DOM, they are simply hidden using a CSS style display: none !important;.

gorhill commented 5 years ago

Works as expected, see documentation regarding cosmetic filtering, known as "element hiding" in ABP: https://adblockplus.org/en/filters#elemhide.

jchook commented 5 years ago

I have attempted HTML filters, e.g.:

my.freshbooks.com##^#zendesk-widget-iframe

Quoting from the documentation:

These HTML filters will cause the elements matching the selectors to be removed from the streamed response data, such that the browser will never know of their existence once it parses the modified response data. This makes it a powerful tool in uBO's arsenal.

Did I use the html filter syntax incorrectly?

jchook commented 5 years ago

@gorhill Oh I see, it's only supported in Firefox?

Is there no way to remove the element in Chromium?

gorhill commented 5 years ago

There is no way to remove elements -- see https://github.com/gorhill/uBlock/issues/2252.

uBlock-user commented 5 years ago

Is there no way to remove the element in Chromium?

You can use a scriptlet for element-removal.

jchook commented 5 years ago

@uBlock-user Thanks for the suggestion. I started looking into that but ended up using TamperMonkey to solve the problem:

// ==UserScript==
// @name         Remove ZenDesk iframe
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Solves a problem with 1Password + Freshbooks
// @author       You
// @match        https://my.freshbooks.com/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var iframe = document.querySelector('#zendesk-widget-iframe');
    if (iframe) {
        iframe.parentNode.removeChild(iframe);
    }

})();
uBlock-user commented 5 years ago

@jchook no need to install TM, just use https://github.com/uBlock-user/uBO-Scriptlets/blob/master/scriptlets.txt#L45

jchook commented 5 years ago

@uBlock-user kind of difficult to figure out how to apply this.

With TM, it's "Just Javascript", takes 5 seconds, and boom it works first try.

With uBlock, I get half-examples for an obscure DSL, I get your link to a .txt file containing several javascript chunks in a different repository... I have to read code to even understand how to pass arguments to scriplets.

Then the docs state:

Keep in mind the resource library is completely under control of the uBO project, hence only javascript code vouched by uBO can be inserted into web pages, through the use of a valid resource token.

Yet eremove.js doesn't appear in the controlled list of resources, and I don't see any mention of loading from uBlock-user repository unless I do a lot of "required reading" and eventually load some file into an advanced setting that "probably will behave in ways unexpected to you".

uBlock-user commented 5 years ago

kind of difficult to figure out how to apply this.

@jchook https://github.com/uBlock-user/uBO-Scriptlets#installation (Only to be done once)

Add filter in My Filters --

my.freshbooks.com##+js(eremove.js, #zendesk-widget-iframe)

krystian3w commented 4 years ago

my.freshbooks.com###zendesk-widget-iframe:remove()

or

my.freshbooks.com#$?##zendesk-widget-iframe { remove: true }