/ contentScript_once_var.js
contentScript_once_var.js
 1  //'use strict';
 2  var ext_api = (typeof browser === 'object') ? browser : chrome;
 3  
 4  var hostname = window.location.hostname;
 5  var de_madsack_domains = ['haz.de', 'kn-online.de', 'ln-online.de', 'lvz.de', 'maz-online.de', 'neuepresse.de', 'ostsee-zeitung.de', 'rnd.de'];
 6  
 7  if (hostname.match(/\.de$/)) {
 8  
 9  if (matchDomain(de_madsack_domains) || document.querySelector('link[href*=".rndtech.de/"]')) {
10    function madsack_main() {
11      for (let n = 0; n < 10; n++) {
12        window.setTimeout(function () {
13          if (window.Fusion) {
14            window.Fusion.globalContent.isPaid = false;
15          }
16        }, n * 50);
17      }
18    }
19    insert_script(madsack_main);
20  }
21  
22  } else if (matchDomain('nzherald.co.nz')) {
23    function nzherald_main() {
24      for (let n = 0; n < 10; n++) {
25        window.setTimeout(function () {
26          if (window.Fusion) {
27            window.Fusion.globalContent.isPremium = false;
28          }
29        }, n * 50);
30      }
31    }
32    insert_script(nzherald_main);
33  }
34  
35  else if (matchDomain('theglobeandmail.com')) {
36    function tgam_main() {
37      for (let n = 0; n < 10; n++) {
38        window.setTimeout(function () {
39          if (window.Fusion) {
40            window.Fusion.globalContent._id = '';
41          }
42        }, n * 50);
43      }
44    }
45    insert_script(tgam_main);
46  }
47  
48  function matchDomain(domains, hostname) {
49    var matched_domain = false;
50    if (!hostname)
51      hostname = window.location.hostname;
52    if (typeof domains === 'string')
53      domains = [domains];
54    domains.some(domain => (hostname === domain || hostname.endsWith('.' + domain)) && (matched_domain = domain));
55    return matched_domain;
56  }
57  
58  function removeDOMElement(...elements) {
59    for (let element of elements) {
60      if (element)
61        element.remove();
62    }
63  }
64  
65  function waitDOMElement(selector, tagName = '', callback, multiple = false) {
66    new window.MutationObserver(function (mutations) {
67      for (let mutation of mutations) {
68        for (let node of mutation.addedNodes) {
69          if (!tagName || (node.tagName === tagName)) {
70            if (node.matches(selector)) {
71              callback(node);
72              if (!multiple)
73                this.disconnect();
74            }
75          }
76        }
77      }
78    }).observe(document, {
79      subtree: true,
80      childList: true
81    });
82  }
83  
84  function insert_script(func, insertAfterDom) {
85    let bpc_script = document.querySelector('script#bpc_script');
86    if (!bpc_script) {
87      let script = document.createElement('script');
88      script.setAttribute('id', 'bpc_script');
89      script.appendChild(document.createTextNode('(' + func + ')();'));
90      let insertAfter = insertAfterDom ? insertAfterDom : (document.body || document.head || document.documentElement);
91      insertAfter.appendChild(script);
92    }
93  }