uBlockProtector icon indicating copy to clipboard operation
uBlockProtector copied to clipboard

ncaa.com

Open lain566 opened this issue 9 years ago • 54 comments

Test link (required):

http://www.ncaa.com/march-madness-live/watch

Screenshot of the web page (required):

ncaa_march_madness_live_-_google_chrome_2017-07-02_17-19-27

Screenshot of the console (press F12 to bring up the console) (required):

ncaa_march_madness_live_-_google_chrome_2017-07-02_17-21-26 ncaa_march_madness_live_-_google_chrome_2017-07-02_17-22-05

lain566 avatar Jul 02 '17 15:07 lain566

https://github.com/reek/anti-adblock-killer/issues/2965#issuecomment-287168823

Does that still work ?

uBlock-user avatar Jul 02 '17 16:07 uBlock-user

@@||ncaa.com^$generichide only helps hiding the message...

jspenguin2017 avatar Jul 02 '17 16:07 jspenguin2017

The video doesn't play ? It used to play back in March, so what changed ?

uBlock-user avatar Jul 02 '17 16:07 uBlock-user

Does it play for you?

jspenguin2017 avatar Jul 02 '17 16:07 jspenguin2017

No, that's why I asked.

uBlock-user avatar Jul 02 '17 16:07 uBlock-user

Probably a bad filter from Easylist and co. Need to investigate what's broken.

uBlock-user avatar Jul 02 '17 16:07 uBlock-user

Looks like they put ads loading inside their player... image

jspenguin2017 avatar Jul 02 '17 20:07 jspenguin2017

This works:

@@||ncaa.com^$generichide

@@||fwmrm.net^$script,domain=ncaa.com
@@||moatads.com^$script,domain=ncaa.com

Real ads are still blocked, good enough for a workaround.

jspenguin2017 avatar Jul 02 '17 20:07 jspenguin2017

a.xhrSpoof from AAK-Cont can be handy in this case... It takes uBO filter as input, we might want to implement that differently for our case.

        /**
         * Modifies the response text of an XHR request.
         * @method xhrSpoof
         * @param urlFilter {String} Matches the request URL based on the adblock/uBlock filter syntax.
         * @param replacement {String} The replacement for the response text.
         */
        xhrSpoof(urlFilter, replacement) {
            this.xhrSpoof.rules.push(this.urlFilterToRegex(urlFilter));
            this.xhrSpoof.replacements.push(replacement);
            if (!this.xhrSpoof.injected) {
                
                let getReplacementIndex = (url) => {
                    let index = -1;
                    for (let i=0; i<this.xhrSpoof.rules.length; i++) {
                        if (this.xhrSpoof.rules[i].test(url)) {
                            index = i;
                            this.xhrSpoof.rules[i].lastIndex = 0;
                            break;
                        }
                    }
                    return index;
                };
                let getReplacementIndexName = this.exportFunction(getReplacementIndex);
                
                let getReplacementValue = (index) => {
                    return this.xhrSpoof.replacements[index];
                };
                let getReplacementValueName = this.exportFunction(getReplacementValue);
                
                this.addScript(`
                    (function(proxied) {
                        var getReplacementIndex = window.${getReplacementIndexName};
                        delete window.${getReplacementIndexName};    
                        var getReplacementValue = window.${getReplacementValueName};
                        delete window.${getReplacementValueName};

                        window.XMLHttpRequest = function() {
                            var wrapped = new(Function.prototype.bind.apply(proxied, arguments));

                            var open = wrapped.open;
                            wrapped.open = function(method, url, async) {
                                    
                                // Determine absolute path
                                var link = document.createElement("a");
                                link.href = url;

                                let replacementIndex = getReplacementIndex(link.protocol+"//"+link.host+link.pathname+link.search+link.hash);
                                if (replacementIndex > -1) {
                                        Object.defineProperty(this, "responseText", {
                                                writable: true,
                                                value: getReplacementValue(replacementIndex)
                                        });
                                }

                                return open.call(wrapped, method, url, async);
                            };

                            return wrapped;
                        };
                    })(XMLHttpRequest);
                `, this.scriptInjectMode.eval);
            }
        }

jspenguin2017 avatar Jul 02 '17 20:07 jspenguin2017

Eh... They use JSONP to load the file... Doesn't go through XMLHttpRequest, must use chrome.webRequest to loopback it... I think just whitelist it is fine, too much work to properly loopback it.

jspenguin2017 avatar Jul 03 '17 04:07 jspenguin2017

Loopback or not, it needs to be whitelisted in uBO. No real ads gets loaded, maybe we should leave this one like this for now...

jspenguin2017 avatar Jul 03 '17 04:07 jspenguin2017

It fetches the streaming API from the ad-server that's why it will remain broken unless whitelisted. The only way to patch this is to replace the player. They purpose fully did that so they can insert their shitty ads anytime they want as long as the domains are whitelisted so this is a compromise, not a solution.

uBlock-user avatar Jul 03 '17 07:07 uBlock-user

Don't have to replace the player, loopback the request is enough, just pretty complex, I might do that, but it needs to be whitelisted in uBO either way or it may interfere with my loopback logic.

If more than one extension attempts to modify the request, the most recently installed extension wins and all others are ignored. An extension is not notified if its instruction to modify or redirect has been ignored.

jspenguin2017 avatar Jul 03 '17 13:07 jspenguin2017

I am able to stop the player from complaining, but the video still doesn't play... image

jspenguin2017 avatar Jul 03 '17 17:07 jspenguin2017

I feel I'm pretty close, I think just the player extension event pump is not right.

jspenguin2017 avatar Jul 03 '17 17:07 jspenguin2017

I just realized that video stream links are in the ads request JSON...

jspenguin2017 avatar Jul 03 '17 18:07 jspenguin2017

I'm going to update background page so the extension is nooped, that's the best I can do, I don't think there is a way to get around sending request to fwmrm.net.

jspenguin2017 avatar Jul 03 '17 18:07 jspenguin2017

I nooped the SDK, alright, good enough.

jspenguin2017 avatar Jul 03 '17 19:07 jspenguin2017

Do we need to whitelist those domains anymore ?

uBlock-user avatar Jul 03 '17 19:07 uBlock-user

Yes, otherwise loopback will be canceled.

a.staticServer(
    [
        "https://*.moatads.com/*/MoatFreeWheelJSPEM.js",
    ],
    [
        "script",
    ],
    "data:text/javascript;base64,KCgpID0+IHsNCiAgICAidXNlIHN0cmljdCI7DQogICAgd2luZG93LmNvbnNvbGUuZXJyb3IoIlVuY2F1Z2h0IEVycm" +
    "9yOiBGcmVlV2hlZWwgU0RLIGlzIG5vdCBhbGxvd2VkIG9uIHRoaXMgZGV2aWNlISIpOw0KICAgIHdpbmRvdy5Nb2F0RnJlZVdoZWVsSlNQRU0gPSBjbGFz" +
    "cyB7DQogICAgICAgIGluaXQoKSB7IH0NCiAgICAgICAgZGlzcG9zZSgpIHsgfQ0KICAgIH07DQp9KSgpOw==",
);

There is no way around sending request to fwmrm.net though.

jspenguin2017 avatar Jul 03 '17 19:07 jspenguin2017