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