浏览代码

Feat: enhance adblock add doubleclick embed script

SukkaW 1 年之前
父节点
当前提交
0bb7dbd312
共有 2 个文件被更改,包括 133 次插入0 次删除
  1. 132 0
      Mock/securepubads-g-doubleclick-net_tag_js_gpt.js
  2. 1 0
      Modules/sukka_enhance_adblock.sgmodule

+ 132 - 0
Mock/securepubads-g-doubleclick-net_tag_js_gpt.js

@@ -0,0 +1,132 @@
+(() => {
+  'use strict';
+
+  // https://developers.google.com/doubleclick-gpt/reference
+  const noopfn = function () {
+    // noop
+  }.bind();
+  const noopthisfn = function () {
+    return this;
+  };
+  const noopnullfn = function () {
+    return null;
+  };
+  const nooparrayfn = function () {
+    return [];
+  };
+  const noopstrfn = function () {
+    return '';
+  };
+  //
+  const companionAdsService = {
+    addEventListener: noopthisfn,
+    enableSyncLoading: noopfn,
+    setRefreshUnfilledSlots: noopfn
+  };
+  const contentService = {
+    addEventListener: noopthisfn,
+    setContent: noopfn
+  };
+  const PassbackSlot = noopfn;
+  let p = PassbackSlot.prototype;
+  p.display = noopfn;
+  p.get = noopnullfn;
+  p.set = noopthisfn;
+  p.setClickUrl = noopthisfn;
+  p.setTagForChildDirectedTreatment = noopthisfn;
+  p.setTargeting = noopthisfn;
+  p.updateTargetingFromMap = noopthisfn;
+  const pubAdsService = {
+    addEventListener: noopthisfn,
+    clear: noopfn,
+    clearCategoryExclusions: noopthisfn,
+    clearTagForChildDirectedTreatment: noopthisfn,
+    clearTargeting: noopthisfn,
+    collapseEmptyDivs: noopfn,
+    defineOutOfPagePassback() { return new PassbackSlot(); },
+    definePassback() { return new PassbackSlot(); },
+    disableInitialLoad: noopfn,
+    display: noopfn,
+    enableAsyncRendering: noopfn,
+    enableLazyLoad: noopfn,
+    enableSingleRequest: noopfn,
+    enableSyncRendering: noopfn,
+    enableVideoAds: noopfn,
+    get: noopnullfn,
+    getAttributeKeys: nooparrayfn,
+    getTargeting: nooparrayfn,
+    getTargetingKeys: nooparrayfn,
+    getSlots: nooparrayfn,
+    refresh: noopfn,
+    removeEventListener: noopfn,
+    set: noopthisfn,
+    setCategoryExclusion: noopthisfn,
+    setCentering: noopfn,
+    setCookieOptions: noopthisfn,
+    setForceSafeFrame: noopthisfn,
+    setLocation: noopthisfn,
+    setPublisherProvidedId: noopthisfn,
+    setPrivacySettings: noopthisfn,
+    setRequestNonPersonalizedAds: noopthisfn,
+    setSafeFrameConfig: noopthisfn,
+    setTagForChildDirectedTreatment: noopthisfn,
+    setTargeting: noopthisfn,
+    setVideoContent: noopthisfn,
+    updateCorrelator: noopfn
+  };
+  const SizeMappingBuilder = noopfn;
+  p = SizeMappingBuilder.prototype;
+  p.addSize = noopthisfn;
+  p.build = noopnullfn;
+  const Slot = noopfn;
+  p = Slot.prototype;
+  p.addService = noopthisfn;
+  p.clearCategoryExclusions = noopthisfn;
+  p.clearTargeting = noopthisfn;
+  p.defineSizeMapping = noopthisfn;
+  p.get = noopnullfn;
+  p.getAdUnitPath = nooparrayfn;
+  p.getAttributeKeys = nooparrayfn;
+  p.getCategoryExclusions = nooparrayfn;
+  p.getDomId = noopstrfn;
+  p.getResponseInformation = noopnullfn;
+  p.getSlotElementId = noopstrfn;
+  p.getSlotId = noopthisfn;
+  p.getTargeting = nooparrayfn;
+  p.getTargetingKeys = nooparrayfn;
+  p.set = noopthisfn;
+  p.setCategoryExclusion = noopthisfn;
+  p.setClickUrl = noopthisfn;
+  p.setCollapseEmptyDiv = noopthisfn;
+  p.setTargeting = noopthisfn;
+  p.updateTargetingFromMap = noopthisfn;
+  //
+  const gpt = window.googletag || {};
+  const cmd = gpt.cmd || [];
+  gpt.apiReady = true;
+  gpt.cmd = [];
+  gpt.cmd.push = function (a) {
+    try {
+      a();
+    } catch {
+    }
+    return 1;
+  };
+  gpt.companionAds = function () { return companionAdsService; };
+  gpt.content = function () { return contentService; };
+  gpt.defineOutOfPageSlot = function () { return new Slot(); };
+  gpt.defineSlot = function () { return new Slot(); };
+  gpt.destroySlots = noopfn;
+  gpt.disablePublisherConsole = noopfn;
+  gpt.display = noopfn;
+  gpt.enableServices = noopfn;
+  gpt.getVersion = noopstrfn;
+  gpt.pubads = function () { return pubAdsService; };
+  gpt.pubadsReady = true;
+  gpt.setAdIframeTitle = noopfn;
+  gpt.sizeMapping = function () { return new SizeMappingBuilder(); };
+  window.googletag = gpt;
+  while (cmd.length !== 0) {
+    gpt.cmd.push(cmd.shift());
+  }
+})();

+ 1 - 0
Modules/sukka_enhance_adblock.sgmodule

@@ -18,3 +18,4 @@ hostname = %APPEND% *.google-analytics.com, *.googletagmanager.com, *.googlesynd
 ^https?://.+\.amazon-adsystem\.com/aax2/apstag\.js https://ruleset.skk.moe/Mock/amazon-adsystem-com_amazon-apstag.js 302
 ^https?://static\.chartbeat\.com/chartbeat\.js https://ruleset.skk.moe/Mock/static-chartbeat-com_chartbeat_mab.js 302
 ^https?://widgets\.outbrain\.com/outbrain\.js https://ruleset.skk.moe/Mock/widgets-outbrain-com_outbrain.js 302
+^https?://securepubads\.g\.doubleclick\.net/tag/js/gpt\.js https://ruleset.skk.moe/Mock/securepubads-g-doubleclick-net_tag_js_gpt.js 302