ソースを参照

Add more to sukka_enhance_adblock.sgmodule

SukkaW 3 年 前
コミット
aedcddff9f

+ 18 - 0
Assets/addthis-com_addthis_widget.js

@@ -0,0 +1,18 @@
+(function () {
+  'use strict';
+  const noopfn = function () {
+  };
+  window.addthis = {
+    addEventListener: noopfn,
+    button: noopfn,
+    counter: noopfn,
+    init: noopfn,
+    layers: noopfn,
+    ready: noopfn,
+    sharecounters: {
+      getShareCounts: noopfn
+    },
+    toolbox: noopfn,
+    update: noopfn
+  };
+})();

+ 13 - 0
Assets/ampproject-org_v0.js

@@ -0,0 +1,13 @@
+(function () {
+  'use strict';
+  const head = document.head;
+  if (!head) { return; }
+  const style = document.createElement('style');
+  style.textContent = [
+    'body {',
+    '  animation: none !important;',
+    '  overflow: unset !important;',
+    '}'
+  ].join('\n');
+  head.appendChild(style);
+})();

+ 1 - 0
Assets/doubleclick-net_instream_ad_status.js

@@ -0,0 +1 @@
+window.google_ad_status = 1;

+ 15 - 0
Assets/www-google-analytics-com_cx_api.js

@@ -0,0 +1,15 @@
+(function () {
+  'use strict';
+  const noopfn = function () {
+  };
+  window.cxApi = {
+    chooseVariation: function () {
+      return 0;
+    },
+    getChosenVariation: noopfn,
+    setAllowHash: noopfn,
+    setChosenVariation: noopfn,
+    setCookiePath: noopfn,
+    setDomainName: noopfn
+  };
+})();

+ 7 - 0
Assets/www-google-analytics-com_inpage_linkid.js

@@ -0,0 +1,7 @@
+(function () {
+  'use strict';
+  window._gaq = window._gaq || {
+    push: function () {
+    }
+  };
+})();

+ 31 - 0
Assets/www-googlesyndication-com_adsbygoogle.js

@@ -0,0 +1,31 @@
+(function () {
+  'use strict';
+  const init = () => {
+    window.adsbygoogle = {
+      loaded: true,
+      push: function () {
+      }
+    };
+    const phs = document.querySelectorAll('.adsbygoogle');
+    const css = 'height:1px!important;max-height:1px!important;max-width:1px!important;width:1px!important;';
+    for (let i = 0; i < phs.length; i++) {
+      const id = `aswift_${i}`;
+      if (document.querySelector(`iframe#${id}`) !== null) { continue; }
+      const fr = document.createElement('iframe');
+      fr.id = id;
+      fr.style = css;
+      const cfr = document.createElement('iframe');
+      cfr.id = `google_ads_frame${i}`;
+      fr.appendChild(cfr);
+      phs[i].appendChild(fr);
+    }
+  };
+  if (
+    document.querySelectorAll('.adsbygoogle').length === 0 &&
+    document.readyState === 'loading'
+  ) {
+    window.addEventListener('DOMContentLoaded', init, { once: true });
+  } else {
+    init();
+  }
+})();

+ 22 - 0
Assets/www-googletagmanager-com_gtm.js

@@ -0,0 +1,22 @@
+(function () {
+  'use strict';
+  const noopfn = function () {
+  };
+  const w = window;
+  w.ga = w.ga || noopfn;
+  const dl = w.dataLayer;
+  if (dl instanceof Object === false) { return; }
+  if (dl.hide instanceof Object && typeof dl.hide.end === 'function') {
+    dl.hide.end();
+  }
+  if (typeof dl.push === 'function') {
+    dl.push = function (o) {
+      if (
+        o instanceof Object &&
+        typeof o.eventCallback === 'function'
+      ) {
+        setTimeout(o.eventCallback, 1);
+      }
+    };
+  }
+})();

+ 132 - 0
Assets/www-googletagservices-com_gpt.js

@@ -0,0 +1,132 @@
+(function () {
+  'use strict';
+  // https://developers.google.com/doubleclick-gpt/reference
+  const noopfn = function () {
+  }.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 = function () {
+  };
+  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: function () { return new PassbackSlot(); },
+    definePassback: function () { return new PassbackSlot(); },
+    disableInitialLoad: noopfn,
+    display: noopfn,
+    enableAsyncRendering: noopfn,
+    enableSingleRequest: noopfn,
+    enableSyncRendering: noopfn,
+    enableVideoAds: noopfn,
+    get: noopnullfn,
+    getAttributeKeys: nooparrayfn,
+    getTargeting: noopfn,
+    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 = function () {
+  };
+  p = SizeMappingBuilder.prototype;
+  p.addSize = noopthisfn;
+  p.build = noopnullfn;
+  const Slot = function () {
+  };
+  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 (ex) {
+    }
+    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());
+  }
+})();

+ 11 - 3
Modules/sukka_enhance_adblock.sgmodule

@@ -3,8 +3,16 @@
 # Use Build/build.js to generate the list
 
 [MITM]
-hostname = %APPEND% *.google-analytics.com
+hostname = %APPEND% *.google-analytics.com, *.googletagmanager.com, *.googlesyndication.com, *.googletagservices.com, *.doubleclick.net, cdn.ampproject.org, *.addthis.com
 
 [URL Rewrite]
-^.+\.google-analytics\.com/analytics\.js https://ruleset.skk.moe/Assets/www-google-analytics-com_analytics.js 302
-^.+\.google-analytics\.com/ga\.js https://ruleset.skk.moe/Assets/www-google-analytics-com_ga.js 302
+^https?://.*\.google-analytics\.com/analytics\.js https://ruleset.skk.moe/Assets/www-google-analytics-com_analytics.js 302
+^https?://.*\.google-analytics\.com/ga\.js https://ruleset.skk.moe/Assets/www-google-analytics-com_ga.js 302
+^https?://.*\.googletagmanager\.com/gtm\.js https://ruleset.skk.moe/Assets/www-googletagmanager-com_gtm.js 302
+^https?://.*\.google-analytics\.com/cx/api\.js https://ruleset.skk.moe/Assets/www-google-analytics-com_cx_api.js 302
+^https?://.*\.googlesyndication\.com/adsbygoogle\.js https://ruleset.skk.moe/Assets/www-googlesyndication-com_adsbygoogle.js 302
+^https?://.*\.googletagservices\.com/gpt\.js https://ruleset.skk.moe/Assets/www-googletagservices-com_gpt.js 302
+^https?://.*\.google-analytics\.com/inpage_linkid\.js https://ruleset.skk.moe/Assets/www-google-analytics-com_inpage_linkid.js 302
+^https?://.*\.doubleclick\.net/instream/ad_status\.js https://ruleset.skk.moe/Assets/doubleclick-net_instream_ad_status.js 302
+^https?://cdn\.ampproject\.org/v0.js https://ruleset.skk.moe/Assets/ampproject-org_v0.js 302
+^https?://.*\.addthis\.com/addthis_widget.js https://ruleset.skk.moe/Assets/addthis-com_addthis_widget.js 302