uBlockOrigin / uAssets

Resources for uBlock Origin, uMatrix: static filter lists, ready-to-use rulesets, etc.
GNU General Public License v3.0
4.13k stars 770 forks source link

nbcsports.com anti-adblock #840

Closed terrorist96 closed 4 years ago

terrorist96 commented 6 years ago

URL(s) where the issue occurs

http://stream.nbcsports.com/rsn/nba-wizards-live-stream

Describe the issue

Anti-adblock.

Screenshot(s)

image

Versions

Settings

Default

Notes

May need to sign in.

okiehsch commented 6 years ago

Well, yes I need to sign in via my "Cable, Satellite, Or Telco TV Provider", which I do not have, so somebody else will have to come up with a solution.

uBlock-user commented 6 years ago

bait - http://stream.nbcsports.com/assets/page/general/ads.js

terrorist96 commented 6 years ago

@@general/ads gets rid of the adblock message, but video still won't play. Adding @@-720x90- will fix it. I think.

mapx- commented 6 years ago

@terrorist96 do you have a working fix ?

terrorist96 commented 6 years ago

No. It's hard to pin down. Plus, this happened on a relative's computer, and I don't have an account either, so I can't readily reproduce it.

jspenguin2017 commented 6 years ago

I have a working solution in Nano Defender:

@@||stream.nbcsports.com^$generichide

then (uses Nano Defender Core):

if (a.domCmp(["stream.nbcsports.com"])) {
    a.loopbackXHR((ignored, url) => {
        if (url.includes(".v.fwmrm.net/ad/g/1")) {
            return `<VAST version='3.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='vast.xsd'>
</VAST>`;
        }
    });
}
if (a.domCmp(["nbcsports.com", "knowyourmeme.com"])) {
    a.readOnly("adblockDetect", () => { });
}
if (a.domCmp(["swissadspaysfaucet.com", "swissadspaysethfaucet.com", "stream.nbcsports.com"])) {
    a.readOnly("adBlockEnabled", false);
}

I'm 99% sure it works, how to implement it in filters is a whole other story.

mapx- commented 6 years ago

could be something like https://github.com/uBlockOrigin/uAssets/issues/218#issuecomment-351215589

? I cannot test the issue.

misha-kotov commented 6 years ago

has anyone else found a solution to this?

mapx- commented 6 years ago

"Cable, Satellite, Or Telco TV Provider" - we need an account

jspenguin2017 commented 6 years ago

Can someone try:

@@||stream.nbcsports.com^$generichide
||v.fwmrm.net/ad/g/1$xmlhttprequest,domain=stream.nbcsports.com,redirect=nano-tiny-noopvast-3.0
nbcsports.com##script:inject(set-constant.js, adblockDetect, noopFunc)
stream.nbcsports.com##script:inject(set-constant.js, adBlockEnabled, false)

nano-tiny-noopvast-3.0 is defined as:

nano-tiny-noopvast-3.0 text/xml
<VAST version="3.0"></VAST>
yourduskquibbles commented 6 years ago

@mapx- the filters suggested by @jspenguin2017 work when I login with xfinity/comcast with the supplied link. This event has ended however so I will also try to also test and confirm with a live event (NHL playoffs) tonight.

yourduskquibbles commented 6 years ago

Getting an adblock warning when I am trying to stream a live event.

Screenshot of adblock message: adblock

logger screenshot: logger

jspenguin2017 commented 6 years ago

Is nano-noopvast-3.0 properly defined in your installation of uBO? This is really difficult to test because the type of account it asks.

yourduskquibbles commented 6 years ago

@jspenguin2017 probably not, using a test profile with default lists and settings & uBO Extra.

What info do you need from me to help fix & if I add the nano resources to advanced settings option will that properly enable nano-noopvast-3.0?

jspenguin2017 commented 6 years ago

if I add the nano resources to advanced settings option will that properly enable nano-noopvast-3.0?

Yes, nano-noopvast-3.0 is part of Nano's extra resources.

jspenguin2017 commented 6 years ago

Oh, actually, it should be nano-tiny-noopvast-3.0. I updated the rules above.

yourduskquibbles commented 6 years ago

Updated the rules to the following

@@||stream.nbcsports.com^$generichide ||v.fwmrm.net/ad/g/1$xmlhttprequest,domain=stream.nbcsports.com,redirect=nano-tiny-noopvast-3.0 nbcsports.com##script:inject(set-constant.js, adblockDetect, noopFunc) stream.nbcsports.com##script:inject(set-constant.js, adBlockEnabled, false)

and added NanoResources to userResourcesLocation and still getting adblock message when I hit the play button on the video.

Screenshot of logger with the nano-tiny-noopvast-3.0 request logger2

jspenguin2017 commented 6 years ago

Can you check if Nano Defender works? The rule is slightly different.

yourduskquibbles commented 6 years ago

@jspenguin2017 Yes! It now seems to work with Nano Defender installed and uBlock Origin Extra 2.71 disabled.

screen

I followed the Extra Installation Steps for Nano Defender for uBlock Origin and added the additional filter lists as well for anyone else finding this issue in the future...

I'm curious, what is the difference in Nano Defender and how can your fixes be incorporated into base uBlock Origin/UBO Extra installation?

jspenguin2017 commented 6 years ago

Do you know how to launch a local server? Create a file with following content:

nano-tiny-noopvast-3.0 text/xml

<?xml version="1.0" encoding="UTF-8"?>
<VAST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vast.xsd" version="3.0">
</VAST>

Put uBO back to default, disable Nano Defender, load the file from local server into uBO's advanced settings, and add rules above. And let me know if it works.

Alternatively, you can give uBO access to your file system and serve the file directly.

jspenguin2017 commented 6 years ago

If that didn't work try this one:

nano-tiny-noopvast-3.0 text/xml

<VAST version='3.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='vast.xsd'>
</VAST>

If it still doesn't work then it becomes pretty complicated, the solution in Nano Defender uses a 1730 lines long library.

yourduskquibbles commented 6 years ago

Assuming I did the local file destination correctly, it doesn't appear to be working when I go back to default filters and uBO + uBO Extra. (I enabled access to file URL's in Extensions page)

One item to note, it seems when Easylist is enabled/disable, the nano-tiny-noopvast-3.0 will be triggered by a different filter. Not sure if that matters at all but including both logger screenshots.

Advanced settings: screen01

Logger with Easylist enabled: easylistlogger

Logger without Easylist enabled: screen02

Adblock message.

screen03

jspenguin2017 commented 6 years ago

the nano-tiny-noopvast-3.0 will be triggered by a different filter from Easylist

That's not going to be a problem, I have a different payload posted above, can you try that too?

yourduskquibbles commented 6 years ago

The alt resources.txt payload also does NOT work. I saved it as a separate txt file with unique name just to make sure it wasn't loading from cache or something.

altpayload

altpayloadsetting

jspenguin2017 commented 6 years ago

Does the console says something about access control allow origin? If yes, then you can try to patch uBO and put the resource in WAR. Otherwise the fix needs to be a pretty big scriptlet, which gorhill won't accept according to his past decisions.

nbcsports.com##+js(nbcsports-defuser.js)
@@||stream.nbcsports.com^$generichide
nbcsports.com##script:inject(set-constant.js, adblockDetect, noopFunc)
stream.nbcsports.com##script:inject(set-constant.js, adBlockEnabled, false)
nbcsports-defuser.js application/javascript

(() => {
        "use strict";
        const server = (ignored, url) => {
        if (url.includes(".v.fwmrm.net/ad/g/1")) {
            return `<VAST version='3.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='vast.xsd'>
</VAST>`;
        }
    };
        let original;
        const newXHR = function (...args) {
            const wrapped = new (window.Function.prototype.bind.apply(original, args));
            const _open = wrapped.open;
            wrapped.open = function (...args) {
                const data = server(...args);
                if (typeof data === "string") {
                    window.Object.defineProperties(this, {
                        "responseText": {
                            configurable: false,
                            set() { },
                            get() {
                                return data;
                            },
                        },
                        "status": {
                            configurable: false,
                            set() { },
                            get() {
                                return 200;
                            },
                        },
                        "statusText": {
                            configurable: false,
                            set() { },
                            get() {
                                return "OK";
                            },
                        },
                    });
                }
                return _open.apply(wrapped, args);
            };
            return wrapped;
        };
        try {
            original = window.XMLHttpRequest;
            window.XMLHttpRequest = newXHR;
        } catch (err) {
            window.console.error("[Nano] Failed :: XMLHttpRequest Loopback Engine");
        }
})();
yourduskquibbles commented 6 years ago

Yes, there is an error for Access-Control-Allow-Credentials in the Console.

fail2

jspenguin2017 commented 6 years ago

If it says Credentials then WAR probably won't work, I haven't tried it but it's over-complicated anyway.

Yea, this would be really difficult to fix with uBO alone. I don't have a better solution. The scriptlet above is the last resort for a pure-uBO solution, otherwise, there is Nano Defender.

yourduskquibbles commented 6 years ago

If a solution can't / won't be added to uBlock Origin I've detailed the steps required to fix this for yourself for anyone finding this in the future.

Fix for adblock message preventing video playback on nbcsports.com

1) Install uBlock Origin 2) Install Nano Defender 3) Follow Nano Defender extra installation steps for uBlock Origin

jspenguin2017 commented 6 years ago

If you use Nano Defender, the custom filters would not be needed. They are included in the integration filter list (although it wouldn't hurt if you added them).

(Or install Nano Adblocker and Nano Defender which saves you 5 steps)

yourduskquibbles commented 6 years ago

Updated to remove step 4 with the custom filters

misha-kotov commented 6 years ago

Thanks for looking into this annoying issue! Cannot wait to try it out. Go Caps! 😬

ghajini commented 6 years ago

https://old.reddit.com/r/uBlockOrigin/comments/8puy6n/how_to_block_ads_on_nbc_agt/ @gorhill working solution described by jspenguin2017 as a ublock origin user ,requires your review

misha-kotov commented 6 years ago

The solution above works for me!