Scriptlets icon indicating copy to clipboard operation
Scriptlets copied to clipboard

Add new scriptlet — 'prevent-constructor'

Open Yuki2718 opened this issue 1 year ago • 2 comments

To prevent constructor such as new Promise or new MutationObserver that can be used to circumvent existing scriptlets like prevent-addEventListener.

Yuki2718 avatar Oct 20 '24 09:10 Yuki2718

Also related - https://github.com/AdguardTeam/AdguardFilters/issues/189250#issuecomment-2396540246 (prevented a new IntersectionObserver if callback contains e[0].intersectionRatio to fix annoying popup).

AdamWr avatar Oct 20 '24 15:10 AdamWr

Related to https://github.com/AdguardTeam/AdguardFilters/issues/204843#issuecomment-3077532042 It seems that mocking MutationObserver can be used here.

Screnshot and code

Image

async function iuag({
  cs: o = false,
  gl: l = false,
  ne: f = false,
  dg: p = false
}) {
  function Pe() {
    try {
      const tt = document.createElement("div");
      tt.className = "banner_ad_wrapper";
      document.body.append(tt);
      const rt = getComputedStyle(tt).display === "none";
      document.body.removeChild(tt);
      if (rt && p) {
        console.log("cs");
      }
      return rt;
    } catch (tt) {
      if (p) {
        console.log(tt);
      }
      return false;
    }
  }
  const Le = o && Pe();
  function Ue() {
    var pt;
    var Ct;
    var At;
    var xt;
    var yt;
    var wt;
    var St;
    const tt = "YnJvd3NpbmdUb3BpY3M=";
    const rt = "am9pbkFkSW50ZXJlc3RHcm91cA==";
    const nt = "cnVuQWRBdWN0aW9u";
    const ot = "bGVhdmVBZEludGVyZXN0R3JvdXA";
    const it = "Y2xlYXJPcmlnaW5Kb2luZWRBZEludGVyZXN0R3JvdXBz";
    const at = "Y2xlYXJBZEludGVyZXN0R3JvdXBz";
    const lt = "Y3JlYXRlQXVjdGlvbk5vbmNl";
    const ut = "dXBkYXRlQWRJbnRlcmVzdEdyb3Vwcw==";
    const ht = "Z2V0QmF0dGVyeQ==";
    const _t = "Z2V0QWRjclVybA==";
    const ct = window.navigator;
    if (typeof Document.prototype[atob(tt)] == "function" && Document.prototype[atob(tt)].name !== atob(tt)) {
      if (p) {
        console.log("a");
      }
      return true;
    } else if (window[atob(_t)] === "") {
      if (p) {
        console.log("b");
      }
      return true;
    } else if (ht in ct && ct[atob(ht)] === undefined) {
      if (p) {
        console.log("c");
      }
      return true;
    } else if (rt in ct && ((pt = ct[atob(rt)]) == null ? undefined : pt.name) !== rt) {
      if (p) {
        console.log("d");
      }
      return true;
    } else if (nt in ct && ((Ct = ct[atob(nt)]) == null ? undefined : Ct.name) !== nt) {
      if (p) {
        console.log("e");
      }
      return true;
    } else if (ot in ct && ((At = ct[atob(ot)]) == null ? undefined : At.name) !== ot) {
      if (p) {
        console.log("f");
      }
      return true;
    } else if (it in ct && ((xt = ct[atob(it)]) == null ? undefined : xt.name) !== it) {
      if (p) {
        console.log("g");
      }
      return true;
    } else if (at in ct && ((yt = ct[atob(at)]) == null ? undefined : yt.name) !== at) {
      if (p) {
        console.log("h");
      }
      return true;
    } else if (lt in ct && ((wt = ct[atob(lt)]) == null ? undefined : wt.name) !== lt) {
      if (p) {
        console.log("i");
      }
      return true;
    } else if (ut in ct && ((St = ct[atob(ut)]) == null ? undefined : St.name) !== ut) {
      if (p) {
        console.log("j");
      }
      return true;
    } else {
      return false;
    }
  }
  function Ge(Je, tt) {
    const ot = "shouldBePrevented";
    return new Promise(it => {
      const ut = new XMLHttpRequest();
      ut.open(tt, Je, true);
      ut.onload = () => {
        it(!!ut[ot] || ut.status === 0);
      };
      ut.onerror = () => {
        it(!!ut[ot] || ut.status === 0);
      };
      ut.send();
    });
  }
  const Xe = l && Ue();
  if (!f) {
    return Le || Xe;
  }
  const Qe = await Promise.all([Ge("https://nam.veta.naver.com/gfp/v1", "OPTIONS"), Ge("https://nam.veta.naver.com/call", "OPTIONS"), Ge("https://nam.veta.naver.com/vas", "OPTIONS")]);
  if (p && Qe.some(Je => Je)) {
    console.log("ne");
  }
  return Le || Xe || Qe.some(Je => Je);
}

piquark6046 avatar Jul 17 '25 00:07 piquark6046