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

Add redirect resource for FreeWheel AdManager.js #401

Open
AdamWr opened this issue Feb 7, 2024 · 0 comments
Open

Add redirect resource for FreeWheel AdManager.js #401

AdamWr opened this issue Feb 7, 2024 · 0 comments
Assignees

Comments

@AdamWr
Copy link
Member

AdamWr commented Feb 7, 2024

Related to this issue - AdguardTeam/AdguardFilters#172374

Video player is broken if https://mssl.fwmrm.net/libs/adm/6.55.0/AdManager.js is blocked.

It seems that something like this:

Code:
(() => {
  const eventsMap = new Map();
  const noopFunc = function () {};
  const noopThis = function () {
    return this;
  };
  const adManagerFunc = noopFunc;
  adManagerFunc.prototype.dispose = noopFunc;
  adManagerFunc.prototype.setNetwork = noopFunc;
  adManagerFunc.prototype.resize = noopFunc;
  adManagerFunc.prototype.setServer = noopFunc;
  adManagerFunc.prototype.setLogLevel = noopFunc;
  adManagerFunc.prototype.newContext = noopThis;
  adManagerFunc.prototype.setParameter = noopFunc;
  adManagerFunc.prototype.addEventListener = function (type, callback) {
    if (type) {
      console.debug(`Type: ${type}, callback: ${callback}`);
      // debugger;
      eventsMap.set(type, callback);
    }
  };
  adManagerFunc.prototype.removeEventListener = noopFunc;
  adManagerFunc.prototype.setProfile = noopFunc;
  adManagerFunc.prototype.setCapability = noopFunc;
  adManagerFunc.prototype.setVideoAsset = noopFunc;
  adManagerFunc.prototype.setSiteSection = noopFunc;
  adManagerFunc.prototype.addKeyValue = noopFunc;
  adManagerFunc.prototype.addTemporalSlot = noopFunc;
  adManagerFunc.prototype.registerCustomPlayer = noopFunc;
  adManagerFunc.prototype.setVideoDisplaySize = noopFunc;
  adManagerFunc.prototype.setContentVideoElement = noopFunc;
  adManagerFunc.prototype.registerVideoDisplayBase = noopFunc;
  adManagerFunc.prototype.submitRequest = function () {
    const event = {
      type: tv.freewheel.SDK.EVENT_SLOT_ENDED
    };
    const func = eventsMap.get('EVENT_SLOT_ENDED');
    // debugger;
    if (func) {
      setTimeout(() => {
        try {
          func(event);
        } catch (ex) {
          console.error(ex);
        }
      }, 1);
    }
  };
  window.tv = {
    freewheel: {
      SDK: {
        Ad: noopFunc,
        AdManager: adManagerFunc,
        AdListener: noopFunc,
        _instanceQueue: {},
        setLogLevel: noopFunc,
        EVENT_SLOT_ENDED: 'EVENT_SLOT_ENDED'
      }
    }
  };
})();

Rule:

southparkstudios.com#%#(()=>{const e=new Map,t=function(){},o=t;o.prototype.dispose=t,o.prototype.setNetwork=t,o.prototype.resize=t,o.prototype.setServer=t,o.prototype.setLogLevel=t,o.prototype.newContext=function(){return this},o.prototype.setParameter=t,o.prototype.addEventListener=function(t,o){t&&(console.debug(`Type: ${t}, callback: ${o}`),e.set(t,o))},o.prototype.removeEventListener=t,o.prototype.setProfile=t,o.prototype.setCapability=t,o.prototype.setVideoAsset=t,o.prototype.setSiteSection=t,o.prototype.addKeyValue=t,o.prototype.addTemporalSlot=t,o.prototype.registerCustomPlayer=t,o.prototype.setVideoDisplaySize=t,o.prototype.setContentVideoElement=t,o.prototype.registerVideoDisplayBase=t,o.prototype.submitRequest=function(){const t={type:tv.freewheel.SDK.EVENT_SLOT_ENDED},o=e.get("EVENT_SLOT_ENDED");o&&setTimeout((()=>{try{o(t)}catch(e){console.error(e)}}),1)},window.tv={freewheel:{SDK:{Ad:t,AdManager:o,AdListener:t,_instanceQueue:{},setLogLevel:t,EVENT_SLOT_ENDED:"EVENT_SLOT_ENDED"}}}})();

fixes issue with video player.

I suppose that it might requires more tweaks, but maybe we could consider to add redirect resource for mssl.fwmrm.net/libs/adm/6.55.0/AdManager.js.

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

3 participants