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

Disabling ublocklite doesn't fully disable it #20

Open
Clashpoint opened this issue Dec 19, 2022 · 11 comments
Open

Disabling ublocklite doesn't fully disable it #20

Clashpoint opened this issue Dec 19, 2022 · 11 comments

Comments

@Clashpoint
Copy link

Clashpoint commented Dec 19, 2022

I am trying to disable ublock completely on some website so I see ads, an example of a website I need the ad block to fully ignore is tab.gladly.io (tab for a cause) , the issue when I fully disable the filters (the extension clearly says no filters and after reloading) it still wouldn't show ads at all .

@gorhill
Copy link
Member

gorhill commented Dec 19, 2022

You need to provide more information if you want me to reproduce on my side, I can't investigate what I can't reproduce. Tell me everything I need to do in details for me to reproduce -- keep in mind I am not behind you looking at your monitor.

@Clashpoint
Copy link
Author

that's fair, I apologize for not being clear , let me know if any more info is needed
I am using google chrome version Version 108.0.5359.125 (Official Build) (64-bit)
while testing this I have only ublock origin lite and tab for a cause as my enabled extensions
these are the errors that I have in my console
chrome_QmByPe4Xzl

and this is whay my ublock shows
kQwgbn1z9O
page with ublock as an active extension with filters fully disabled
chrome_3uXRbSXtIB
and the page when it's disabled as an extension
chrome_RjND67C8mC
tho even while disabled I am getting these errors in my console
chrome_w2Q1mYfrNg

@gorhill
Copy link
Member

gorhill commented Dec 19, 2022

What's your default filtering mode in uBO Lite?

@Clashpoint
Copy link
Author

default filtering mode is optimal with these filters
chrome_7TPjmfALQx

@gorhill
Copy link
Member

gorhill commented Dec 19, 2022

The problem does not occur when default mode is set to Basic.

Unfortunately, I do not know how this can be fixed, as there is no way to tell the scripting API to declaratively exclude script injection according to the root context. Another limitation is that with the permissions API there is no way to exclude a specific site from an extension.

For now the only workaround I see is to work in Basic mode by default, and enable higher blocking modes only for specific sites.


The CSS style being injected in the Google Ad frame:

Screenshot from 2022-12-19 12-55-01

I might open an issue with MV3 people to make them aware of this sort of issues.

@Clashpoint
Copy link
Author

I see, thanks for the reply

@erock8303
Copy link

This issue is affecting other extensions from being used on specific sites for me and my team.

We use Hubspot for our sales emails to track and log them in our CRM. Their Hubspot Sales Extension allows us to do this within the Gmail interface. Unfortunately, uBOL does not completely "turn off" when I select 'no filtering' on mail.google.com. The Hubspot extension fails every time uBOL is installed. It works when uBOL is uninstalled. uBOL is our companies only allowed adblocker.

I've worked with Hubspot support team and have exhausted all options to work around uBOL. They provided a list of their domains that I added to uBOL's "allow" list, but no change to the failing functionality.

Any suggestions?

Let me know if you need any more info, screenshots, or anything else. We would really appreciate your help in solving this issue.

@gorhill
Copy link
Member

gorhill commented Jul 19, 2024

This can only be solved by the browser API providing new functionality to the scripting.registerContentScripts equivalent to DNR's allowAllRequests.

@gorhill
Copy link
Member

gorhill commented Aug 5, 2024

Following the discussion at w3c/webextensions#668, I did try the suggestion to use a synchronous XHR-based hacky solution, and I have a prototype which solves the issue. It works this way:

Create a dynamic DNR rule as follow

{
    id: ALLOWALL_HACK,
    action: {
        type: 'redirect',
        redirect: {
            extensionPath: '/web_accessible_resources/filtering-enabled'
        },
    },
    condition: {
        resourceTypes: [ 'xmlhttprequest' ],
        urlFilter: '|https://ubol.invalid/filtering/',
    },
    priority: 100,
}

priority is set to the same priority used to declare the allowAllRequests rules used to implement the no-filtering mode, hence only those allowAllRequests can bypass the ALLOWALL_HACK rule.

Content script side, there is this code:

// https://github.com/uBlockOrigin/uBOL-home/issues/20
// https://github.com/w3c/webextensions/issues/668
// Hacky, until a better solution is possible in MV3.
// If the xhr fails, this means the request was not redirected to a local
// resource by the extension, which indicates that no-filtering mode is in
// effect for the root context.
{
    const ancestors = document.location.ancestorOrigins;
    if ( ancestors && ancestors.length !== 0 ) {
        const rootOrigin = ancestors.item(ancestors.length-1);
        if ( rootOrigin !== document.location.origin ) {
            const xhr = new XMLHttpRequest();
            try {
                xhr.open('GET', `https://ubol.invalid/filtering/`, false);
                xhr.send();
            } catch(ex) {
                return; // no filtering should occur
            }
        }
    }
}

So when disabling filtering for example.com, an allowAllRequests rule is created for example.com, which will cause the ALLOWALL_HACK rule to be disabled when example.com is one of the ancestor, and the content script will return immediately as a result.

However this comes at the cost of undesirable side effects:

https://ubol.invalid/filtering/ is not secret, so websites could use it to find out whether uBOL is installed and enabled. A per-release random part could be used but the URL would still be public and usable for the duration of the release

With sites for which uBOL is disabled, the console may be polluted by numerous error messages because https://ubol.invalid/filtering/ is unreachable:

image

@stephenhawk8054
Copy link
Member

https://ubol.invalid/filtering/ is not secret, so websites could use it to find out whether uBOL is installed and enabled. A per-release random part could be used but the URL would still be public and usable for the duration of the release

Hmm... That sounds like a trivial way for websites' anti-adblock?

@gorhill
Copy link
Member

gorhill commented Aug 5, 2024

That sounds like a trivial way for websites' anti-adblock?

Yes, hence why it's unlikely I go ahead with this fix, it was just a proof of concept that this can be done, but there is a cost. The real solution would be for uBOL to be able to dynamically register data to be injected in isolated and main world and accessible to registered scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants