-
Notifications
You must be signed in to change notification settings - Fork 5
/
contentScript.js
executable file
·3559 lines (3307 loc) · 141 KB
/
contentScript.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//"use strict";
var ext_api = (typeof browser === 'object') ? browser : chrome;
var domain;
var csDone = false;
var csDoneOnce = false;
var dompurify_loaded = (typeof DOMPurify === 'function');
var ca_torstar_domains = ['niagarafallsreview.ca', 'stcatharinesstandard.ca', 'thepeterboroughexaminer.com', 'therecord.com', 'thespec.com', 'thestar.com', 'wellandtribune.ca'];
var de_funke_media_domains = ['abendblatt.de', 'braunschweiger-zeitung.de', 'morgenpost.de', 'nrz.de', 'otz.de', 'thueringer-allgemeine.de', 'tlz.de', 'waz.de', 'wp.de', 'wr.de'];
var de_madsack_domains = ['haz.de', 'kn-online.de', 'ln-online.de', 'lvz.de', 'maz-online.de', 'neuepresse.de', 'ostsee-zeitung.de'];
var es_epiberica_domains = ['diariodeibiza.es', 'diariodemallorca.es', 'eldia.es', 'elperiodicomediterraneo.com', 'farodevigo.es', 'informacion.es', 'laprovincia.es', 'levante-emv.com', 'lne.es'];
var es_grupo_vocento_domains = ['diariosur.es', 'diariovasco.com', 'elcomercio.es', 'elcorreo.com', 'eldiariomontanes.es', 'elnortedecastilla.es', 'hoy.es', 'ideal.es', 'larioja.com', 'lasprovincias.es', 'laverdad.es', 'lavozdigital.es'];
var es_unidad_domains = ['elmundo.es', 'expansion.com', 'marca.com'];
var fi_alma_talent_domains = ['arvopaperi.fi', 'iltalehti.fi', 'kauppalehti.fi', 'marmai.fi', 'mediuutiset.fi', 'mikrobitti.fi', 'talouselama.fi', 'tekniikkatalous.fi', 'tivi.fi', 'uusisuomi.fi'];
var fr_groupe_ebra_domains = ['bienpublic.com', 'dna.fr', 'estrepublicain.fr', 'lalsace.fr', 'ledauphine.com', 'lejsl.com', 'leprogres.fr', 'republicain-lorrain.fr', 'vosgesmatin.fr'];
var fr_groupe_la_depeche_domains = ['centrepresseaveyron.fr', 'ladepeche.fr', 'lindependant.fr', 'midi-olympique.fr', 'midilibre.fr', 'nrpyrenees.fr', 'petitbleu.fr'];
var fr_groupe_nice_matin_domains = ['monacomatin.mc', 'nicematin.com', 'varmatin.com'];
var it_ilmessaggero_domains = ['corriereadriatico.it', 'ilgazzettino.it', 'ilmattino.it', 'ilmessaggero.it', 'quotidianodipuglia.it'];
var it_repubblica_domains = ['gelocal.it', 'ilsecoloxix.it', 'italian.tech', 'lanuovasardegna.it', 'lastampa.it', 'repubblica.it'];
var it_quotidiano_domains = ['ilgiorno.it', 'ilrestodelcarlino.it', 'iltelegrafolivorno.it', 'lanazione.it', 'quotidiano.net'];
var nl_mediahuis_region_domains = ['gooieneemlander.nl', 'haarlemsdagblad.nl', 'ijmuidercourant.nl', 'leidschdagblad.nl', 'noordhollandsdagblad.nl'];
var no_nhst_media_domains = ['intrafish.com', 'rechargenews.com', 'tradewindsnews.com', 'upstreamonline.com'];
var timesofindia_domains = ['timesofindia.com', 'timesofindia.indiatimes.com'];
var usa_adv_local_domains = ['al.com', 'cleveland.com', 'lehighvalleylive.com', 'masslive.com', 'mlive.com', 'nj.com', 'oregonlive.com', 'pennlive.com', 'silive.com', 'syracuse.com'];
var usa_craincomm_domains = ['adage.com', 'autonews.com', 'chicagobusiness.com', 'crainscleveland.com', 'crainsdetroit.com', 'crainsnewyork.com', 'modernhealthcare.com'];
var usa_hearst_comm_domains = ['expressnews.com', 'houstonchronicle.com', 'sfchronicle.com'];
var usa_lee_ent_domains = ['buffalonews.com', 'richmond.com', 'tucson.com', 'tulsaworld.com'];
var usa_mcc_domains = ['bnd.com', 'charlotteobserver.com', 'fresnobee.com', 'kansas.com', 'kansascity.com', 'kentucky.com', 'miamiherald.com', 'newsobserver.com', 'sacbee.com', 'star-telegram.com', 'thestate.com', 'tri-cityherald.com'];
var usa_mng_domains = ['denverpost.com', 'eastbaytimes.com', 'mercurynews.com', 'ocregister.com', 'pe.com', 'twincities.com'];
var usa_tribune_domains = ['baltimoresun.com', 'chicagotribune.com', 'courant.com', 'dailypress.com', 'mcall.com', 'nydailynews.com', 'orlandosentinel.com', 'pilotonline.com', 'sun-sentinel.com'];
// clean local storage of sites (with an exemption for hold-list)
var arr_localstorage_hold = ['aachener-nachrichten.de', 'aachener-zeitung.de', 'allgaeuer-zeitung.de', 'augsburger-allgemeine.de', 'barrons.com', 'businessoffashion.com', 'charliehebdo.fr', 'cmjornal.pt', 'corriere.it', 'elespanol.com', 'estadao.com.br', 'fortune.com', 'ilfoglio.it', 'inc42.com', 'kurier.at', 'nknews.org', 'ruhrnachrichten.de', 'scmp.com', 'seekingalpha.com', 'telegraph.co.uk', 'thehindu.com', 'thetimes.co.uk', 'wsj.com'].concat(de_funke_media_domains, es_grupo_vocento_domains, es_unidad_domains, fr_groupe_ebra_domains, fr_groupe_la_depeche_domains, fr_groupe_nice_matin_domains, it_quotidiano_domains, no_nhst_media_domains, usa_hearst_comm_domains);
if (!matchDomain(arr_localstorage_hold)) {
window.localStorage.clear();
}
var div_bpc_done = document.querySelector('div#bpc_done');
if (!div_bpc_done) {
var bg2csData;
// check for opt-in confirmation (from background.js)
if ((bg2csData !== undefined) && bg2csData.optin_setcookie) {
if (domain = matchDomain(['belfasttelegraph.co.uk', 'independent.ie'])) {
if (!cookieExists('subscriber'))
setCookie('subscriber', '{"subscriptionStatus": true}', domain, '/', 14);
}
}
function amp_iframes_replace(weblink = false) {
let amp_iframes = document.querySelectorAll('amp-iframe');
let elem;
for (let amp_iframe of amp_iframes) {
if (!weblink) {
elem = document.createElement('iframe');
Object.assign(elem, {
src: amp_iframe.getAttribute('src'),
sandbox: amp_iframe.getAttribute('sandbox'),
height: amp_iframe.getAttribute('height'),
width: 'auto',
style: 'border: 0px;'
});
} else {
elem = document.createElement('a');
elem.innerText = 'Video-link';
elem.setAttribute('href', amp_iframe.getAttribute('src'));
elem.setAttribute('target', '_blank');
}
amp_iframe.parentElement.insertBefore(elem, amp_iframe);
removeDOMElement(amp_iframe);
}
}
function amp_unhide_subscr_section(amp_ads_sel = 'amp-ad, .ad', replace_iframes = true, amp_iframe_link = false) {
let preview = document.querySelector('[subscriptions-section="content-not-granted"]');
removeDOMElement(preview);
let subscr_section = document.querySelectorAll('[subscriptions-section="content"]');
for (let elem of subscr_section)
elem.removeAttribute('subscriptions-section');
let amp_ads = document.querySelectorAll(amp_ads_sel);
removeDOMElement(...amp_ads);
if (replace_iframes)
amp_iframes_replace(amp_iframe_link);
}
function amp_unhide_access_hide(amp_access = '', amp_access_not = '', amp_ads_sel = 'amp-ad, .ad', replace_iframes = true, amp_iframe_link = false) {
let access_hide = document.querySelectorAll('[amp-access' + amp_access + '][amp-access-hide]');
for (elem of access_hide)
elem.removeAttribute('amp-access-hide');
if (amp_access_not) {
let amp_access_not_dom = document.querySelector('[amp-access' + amp_access_not + ']');
removeDOMElement(amp_access_not_dom);
}
let amp_ads = document.querySelectorAll(amp_ads_sel);
removeDOMElement(...amp_ads);
if (replace_iframes)
amp_iframes_replace(amp_iframe_link);
}
// custom sites: try to unhide text on amp-page
if ((bg2csData !== undefined) && bg2csData.amp_unhide) {
window.setTimeout(function () {
let amp_page_hide = document.querySelector('script[src*="/amp-access-"], script[src*="/amp-subscriptions-"]');
if (amp_page_hide) {
amp_unhide_subscr_section();
amp_unhide_access_hide();
amp_iframes_replace();
}
}, 100); // Delay (in milliseconds)
}
// updated sites: amp-redirect
if ((bg2csData !== undefined) && bg2csData.amp_redirect) {
window.setTimeout(function () {
let amp_script = document.querySelector('script[src^="https://cdn.ampproject.org/"]');
let amphtml = document.querySelector('link[rel="amphtml"]');
let amp_page = amp_script && !amphtml;
if (!amp_page) {
let paywall = true;
if (bg2csData.amp_redirect.paywall)
paywall = document.querySelector(bg2csData.amp_redirect.paywall);
if (paywall && amphtml) {
removeDOMElement(paywall);
window.location.href = amphtml.href;
}
}
}, 500); // Delay (in milliseconds)
}
function cs_code_elems(elems) {
for (let elem of elems) {
let elem_dom = document.querySelectorAll(elem.cond);
for (let item of elem_dom) {
if (elem.rm_elem)
removeDOMElement(item);
if (elem.rm_class) {
let rm_class = elem.rm_class.split(',').map(x => x.trim());
item.classList.remove(...rm_class);
}
if (elem.rm_attrib)
item.removeAttribute(elem.rm_attrib);
if (elem.elems)
cs_code_elems(elem.elems);
}
}
}
// updated sites: cs_code
if ((bg2csData !== undefined) && bg2csData.cs_code) {
window.setTimeout(function () {
cs_code_elems(bg2csData.cs_code);
}, 1000); // Delay (in milliseconds)
}
// Content workarounds/domain
if (matchDomain(['medium.com', 'towardsdatascience.com']) || document.querySelector('script[src^="https://cdn-client.medium.com/"]')) {
let paywall = document.querySelector('div#paywall-background-color');
removeDOMElement(paywall);
if (paywall) {
ext_api.runtime.sendMessage({request: 'refreshCurrentTab'});
csDoneOnce = true;
}
window.setTimeout(function () {
let meter = document.querySelector('[id*="highlight-meter-"]');
if (meter)
meter.hidden = true;
}, 500); // Delay (in milliseconds)
}
else if (window.location.hostname.match(/\.(com|net)\.au$/)) {//australia
if (matchDomain('thesaturdaypaper.com.au')) {
let paywall = document.querySelector('div.paywall-hard-always-show');
removeDOMElement(paywall);
}
else if (domain = matchDomain(["brisbanetimes.com.au", "smh.com.au", "theage.com.au", "watoday.com.au"])) {
let url = window.location.href;
let for_subscribers = document.querySelector('meta[content^="FOR SUBSCRIBERS"], #paywall_prompt');
if (for_subscribers) {
window.setTimeout(function () {
window.location.href = url.replace('www.', 'amp.');
}, 500); // Delay (in milliseconds)
} else if (url.includes('amp.' + domain)) {
amp_unhide_subscr_section();
}
}
else {
// Australian Community Media newspapers
let au_cm_sites = ['bendigoadvertiser.com.au', 'bordermail.com.au', 'canberratimes.com.au', 'centralwesterndaily.com.au', 'dailyadvertiser.com.au', 'dailyliberal.com.au', 'examiner.com.au', 'illawarramercury.com.au', 'newcastleherald.com.au', 'northerndailyleader.com.au', 'portnews.com.au', 'standard.net.au', 'theadvocate.com.au', 'thecourier.com.au', 'westernadvocate.com.au'];
let au_piano_script = document.querySelector('script[src="https://cdn-au.piano.io/api/tinypass.min.js"]');
if (matchDomain(au_cm_sites) || au_piano_script) {
let subscribe_truncate = document.querySelector('.subscribe-truncate');
if (subscribe_truncate)
subscribe_truncate.classList.remove('subscribe-truncate');
let subscriber_hiders = document.querySelectorAll('.subscriber-hider');
for (let subscriber_hider of subscriber_hiders)
subscriber_hider.classList.remove('subscriber-hider');
let blocker = document.querySelector('div.blocker');
let noscroll = document.querySelector('body[style]');
if (noscroll)
noscroll.removeAttribute('style');
let story_generic_iframe = document.querySelector('.story-generic__iframe');
removeDOMElement(story_generic_iframe, blocker);
} else if (window.location.hostname.endsWith('.com.au')) {
// Australia News Corp
let au_nc_sites = ['adelaidenow.com.au', 'cairnspost.com.au', 'codesports.com.au', 'couriermail.com.au', 'dailytelegraph.com.au', 'geelongadvertiser.com.au', 'goldcoastbulletin.com.au', 'heraldsun.com.au', 'ntnews.com.au', 'theaustralian.com.au', 'thechronicle.com.au', 'themercury.com.au', 'townsvillebulletin.com.au', 'weeklytimesnow.com.au'];
if (domain = matchDomain(au_nc_sites)) {
let header_ads = document.querySelector('.header_ads-container');
removeDOMElement(header_ads);
let amp_ads_sel = 'amp-ad, amp-embed, [id^="ad-mrec-"], .story-ad-container';
if (window.location.hostname.startsWith('amp.')) {
amp_unhide_access_hide('="access AND subscriber"', '', amp_ads_sel, true, true);
} else if (window.location.href.includes('?amp')) {
amp_unhide_access_hide('="subscriber AND status=\'logged-in\'"', '', amp_ads_sel, true, true);
}
} else {
// Australian Seven West Media
let swm_script = document.querySelector('script[src^="https://s.thewest.com.au"]');
if (matchDomain('thewest.com.au') || swm_script) {
window.setTimeout(function () {
let breach_screen = document.querySelector('div[data-testid*="BreachScreen"]');
if (breach_screen) {
let scripts = document.querySelectorAll('script:not([src], [type])');
let json_script;
for (let script of scripts) {
if (script.innerText.includes('window.PAGE_DATA =')) {
json_script = script;
break;
}
}
if (json_script) {
let json_text = json_script.innerHTML.split('window.PAGE_DATA =')[1].split('</script')[0];
json_text = json_text.replace(/undefined/g, '"undefined"');
let json_article = JSON.parse(json_text);
let json_pub;
for (let key in json_article)
if (json_article[key].data.result.resolution && json_article[key].data.result.resolution.publication) {
json_pub = json_article[key].data.result.resolution.publication;
break;
}
let json_content = [];
let url_loaded;
if (json_pub) {
json_content = json_pub.content.blocks;
url_loaded = json_pub._self;
} else
window.location.reload(true);
//let json_video = json_pub.mainVideo;
let url = window.location.href;
if (!url_loaded || !url.includes(url_loaded.slice(-10)))
window.location.reload(true);
let par_elem, par_sub1, par_sub2;
let par_dom = document.createElement('div');
let tweet_id = 1;
for (let par of json_content) {
par_elem = '';
if (par.kind === 'text') {
par_elem = document.createElement('p');
par_elem.innerText = par.text;
} else if (par.kind === 'subhead') {
par_elem = document.createElement('h2');
par_elem.innerText = par.text;
} else if (par.kind === 'pull-quote') {
par_elem = document.createElement('i');
par_elem.innerText = (par.attribution ? par.attribution + ': ' : '') + par.text;
} else if (par.kind === 'embed') {
if (par.reference.includes('https://omny.fm/') || par.reference.includes('https://docdro.id/')) {
par_elem = document.createElement('embed');
par_elem.src = par.reference;
par_elem.style = 'height:500px; width:100%';
par_elem.frameborder = '0';
} else {
par_elem = document.createElement('a');
par_elem.href = par.reference;
par_elem.innerText = par.reference.split('?')[0];
console.log('embed: ' + par.reference);
}
} else if (par.kind === 'unordered-list') {
if (par.items) {
par_elem = document.createElement('ul');
for (let item of par.items)
if (item.text) {
par_sub1 = document.createElement('li');
if (item.intentions[0] && item.intentions[0].href) {
par_sub2 = document.createElement('a');
par_sub2.href = item.intentions[0].href;
} else {
par_sub2 = document.createElement('span');
}
par_sub2.innerText = item.text;
par_sub1.appendChild(par_sub2);
par_elem.appendChild(par_sub1);
}
}
} else if (par.kind === 'inline') {
if (par.asset.kind === 'image') {
par_elem = document.createElement('figure');
par_sub1 = document.createElement('img');
par_sub1.src = par.asset.original.reference;
par_sub1.style = 'width:100%';
par_elem.appendChild(par_sub1);
if (par.asset.captionText) {
par_sub2 = document.createElement('figcaption');
par_sub2.innerText = par.asset.captionText + ' ' + par.asset.copyrightByline +
((par.asset.copyrightCredit && par.asset.captionText !== par.asset.copyrightByline) ? '/' + par.asset.copyrightCredit : '');
par_elem.appendChild(par_sub2);
}
}
} else {
par_elem = document.createElement('p');
par_elem.innerText = par.text;
console.log(par.kind);
}
if (par_elem)
par_dom.appendChild(par_elem);
}
let content = document.querySelector('div[class*="StyledArticleContent"]');
if (content) {
content.appendChild(par_dom);
} else {
par_dom.setAttribute('style', 'margin: 20px;');
breach_screen.parentElement.insertBefore(par_dom, breach_screen);
}
}
removeDOMElement(breach_screen);
}
}, 1500); // Delay (in milliseconds)
let header_advert = document.querySelector('.headerAdvertisement');
if (header_advert)
header_advert.setAttribute('style', 'display: none;');
}
}
}
else
csDone = true;
}
} else if (window.location.hostname.match(/\.(de|at|ch)$/) || matchDomain(['faz.net', 'handelsblatt.com'])) {//germany/austria/switzerland - ch
if (matchDomain(['aachener-nachrichten.de', 'aachener-zeitung.de'])) {
let url = window.location.href;
if (url.includes('?output=amp')) {
amp_unhide_subscr_section('amp-ad, amp-embed');
} else {
let paywall = document.querySelector('.park-article-paywall, .text-blurred');
let amphtml = document.querySelector('link[rel="amphtml"]');
if (paywall && amphtml) {
removeDOMElement(paywall);
window.location.href = amphtml.href;
}
}
}
else if (matchDomain('allgaeuer-zeitung.de')) {
let url = window.location.href;
if (!url.includes('?type=amp')) {
let paywall = document.querySelector('p.nfy-text-blur');
if (paywall) {
removeDOMElement(paywall);
window.location.href = url.split('?')[0] + '?type=amp';
}
} else {
let preview = document.querySelectorAll('p.nfy-text-blur, div[subscriptions-display^="NOT data."]');
let amp_ads = document.querySelectorAll('amp-ad');
removeDOMElement(...preview, ...amp_ads);
}
}
else if (matchDomain('augsburger-allgemeine.de')) {
let url = window.location.href;
if (!url.includes('-amp.html')) {
let paywall = document.querySelector('div.aa-visible-logged-out');
if (paywall) {
removeDOMElement(paywall);
window.location.href = url.replace('.html', '-amp.html');
}
} else {
amp_unhide_subscr_section();
}
}
else if (matchDomain('berliner-zeitung.de')) {
let url = window.location.href;
let paywall = document.querySelector('.paywall-dialog-box');
if (url.split('?')[0].includes('.amp')) {
if (paywall) {
removeDOMElement(paywall);
amp_unhide_subscr_section();
}
} else {
if (paywall) {
removeDOMElement(paywall);
window.location.href = url.split('?')[0] + '.amp';
}
}
}
else if (matchDomain('cicero.de')) {
let url = window.location.href;
if (!url.includes('?amp')) {
let paywall = document.querySelector('.plenigo-paywall');
if (paywall) {
removeDOMElement(paywall);
let url_amp = url + '?amp';
replaceDomElementExt(url_amp, false, false, '.field-name-field-cc-body');
}
} else {
let teasered_content = document.querySelector('.teasered-content');
if (teasered_content)
teasered_content.classList.remove('teasered-content');
let teasered_content_fader = document.querySelector('.teasered-content-fader');
let btn_read_more = document.querySelector('.btn--read-more');
let amp_ads = document.querySelectorAll('amp-ad');
removeDOMElement(teasered_content_fader, btn_read_more, ...amp_ads);
}
let urban_ad_sign = document.querySelectorAll('.urban-ad-sign');
removeDOMElement(...urban_ad_sign);
}
else if (matchDomain(de_funke_media_domains)) {
if (window.location.search.startsWith('?service=amp'))
amp_unhide_access_hide('="NOT p.showRegWall AND NOT p.showPayWall"', '', 'amp-ad, amp-embed, amp-fx-flying-carpet');
else
sessionStorage.setItem('deobfuscate', 'true');
}
else if (matchDomain('deutsche-wirtschafts-nachrichten.de')) {
window.setTimeout(function () {
let hardpay = document.querySelector('.hardpay');
if (hardpay) {
window.location.reload(true);
}
}, 500); // Delay (in milliseconds)
}
else if (matchDomain('faz.net')) {
if (matchDomain('zeitung.faz.net')) {
let paywall_z = document.querySelector('.c-red-carpet');
if (paywall_z) {
let og_url = document.querySelector('meta[property="og:url"]');
if (og_url)
window.setTimeout(function () {
window.location.href = og_url.content;
}, 500); // Delay (in milliseconds)
}
let sticky_advt = document.querySelector('.sticky-advt');
removeDOMElement(sticky_advt);
} else {
let paywall = document.querySelector('#paywall-form-container-outer, .atc-ContainerPaywall');
if (paywall) {
removeDOMElement(paywall);
let url = new URL(window.location.href);
let mUrl = new URL(url.pathname, 'https://m.faz.net/');
fetch(mUrl)
.then(response => {
if (response.ok) {
response.text().then(html => {
let parser = new DOMParser();
let doc = parser.parseFromString(html, 'text/html');
let json = doc.querySelector('script[id="schemaOrgJson"]');
if (json) {
let json_text = json.text.replace(/(\r|\n)/g, '');
let split1 = json_text.split('"ArticleBody": "');
let split2 = split1[1].split('","author":');
if (split2[0].includes('"'))
json_text = split1[0] + '"ArticleBody": "' + split2[0].replace(/"/g, '“') + '","author":' + split2[1];
try {
json_text = JSON.parse(json_text).ArticleBody;
} catch (err) {
console.log(err);
return;
}
if (!json_text)
return;
let article_text = document.querySelector('.art_txt.paywall,.atc-Text.js-atc-Text');
article_text.innerText = '';
json_text = breakText(json_text);
json_text.split("\n\n").forEach(
(p_text) => {
let elem;
if (p_text.length < 80) {
elem = document.createElement("h2");
elem.setAttribute('class', 'atc-SubHeadline');
} else {
elem = document.createElement("p");
elem.setAttribute('class', 'atc-TextParagraph');
};
elem.innerText = p_text;
article_text.appendChild(elem);
});
}
})
}
});
}
let lay_paysocial = document.querySelector('div.lay-PaySocial');
removeDOMElement(lay_paysocial);
}
}
else if (matchDomain('freiepresse.de')) {
let url = window.location.href;
let article_teaser = document.querySelector('div.article-teaser');
if (article_teaser && url.match(/(\-artikel)(\d){6,}/)) {
window.setTimeout(function () {
window.location.href = url.replace('-artikel', '-amp');
}, 500); // Delay (in milliseconds)
} else if (url.match(/(\-amp)(\d){6,}/)) {
let amp_ads = document.querySelectorAll('amp-fx-flying-carpet, amp-ad, amp-embed');
let pw_layer = document.querySelector('.pw-layer');
removeDOMElement(...amp_ads, pw_layer);
}
}
else if (matchDomain('handelsblatt.com')) {
let url = window.location.href;
if (url.match(/\/amp(\d)?\./)) {
let amp_ads = document.querySelectorAll('amp-ad, amp-embed');
removeDOMElement(...amp_ads);
} else {
let paywall = document.querySelector('div.temp-paywall1');
let amphtml = document.querySelector('link[rel="amphtml"]');
if (paywall && amphtml) {
removeDOMElement(paywall);
let premium = document.querySelector('meta[content*="PREMIUM"]');
if (!premium)
window.location.href = amphtml.href;
}
}
}
else if (matchDomain('krautreporter.de')) {
let paywall = document.querySelector('.article-paywall');
if (paywall) {
let paywall_divider = document.querySelector('.js-paywall-divider');
let steady_checkout = document.querySelector('#steady-checkout');
removeDOMElement(paywall, paywall_divider, steady_checkout);
let blurred = document.querySelectorAll('.blurred');
for (let elem of blurred)
elem.classList.remove('blurred', 'json-ld-paywall-marker', 'hidden@print');
}
}
else if (matchDomain(['ksta.de', 'rundschau-online.de'])) {
let paywall = document.querySelector('.pay.wall');
if (paywall) {
removeDOMElement(paywall);
let scripts = document.querySelectorAll('script[type="application/ld+json"]');
let json;
for (let script of scripts) {
if (script.innerText.includes('articleBody'))
json = script;
}
if (json) {
let json_text = JSON.parse(json.text).articleBody;
json_text = parseHtmlEntities(json_text);
json_text = breakText(json_text);
let region = 'ortsmarke';
if (window.location.hostname === 'mobil.ksta.de')
region = 'district';
let article_sel = 'div.article-text > p.selectionShareable:not(.' + region + '), div.dm_article_text > p.selectionShareable:not(.' + region + ')';
let article = document.querySelector(article_sel);
if (article && json_text) {
article.innerText = json_text;
}
}
}
}
else if (matchDomain('kurier.at')) {
let view_offer = document.querySelector('.view-offer');
removeDOMElement(view_offer);
let plus_content = document.querySelector('.plusContent');
if (plus_content)
plus_content.classList.remove('plusContent');
}
else if (matchDomain('mz.de')) {
let url = window.location.href.split('?')[0];
let paywall = document.querySelector('.fp-paywall');
if (url.includes('/amp/')) {
amp_unhide_subscr_section('amp-ad, amp-embed');
} else {
if (paywall) {
removeDOMElement(paywall);
window.location.href = window.location.href.replace('.de/', '.de/amp/');
}
}
}
else if (matchDomain(['noz.de', 'nwzonline.de', 'shz.de', 'svz.de'])) {
let url = window.location.href;
if (url.includes('?amp') || url.includes('-amp.html')) {
amp_unhide_access_hide('="NOT data.reduced"', '="data.reduced"', 'amp-ad, amp-embed, #flying-carpet-wrapper');
} else {
let paywall = document.querySelector('.paywall, .story--premium__container');
let amphtml = document.querySelector('link[rel="amphtml"]');
if (paywall && amphtml) {
removeDOMElement(paywall);
window.location.href = amphtml.href;
}
}
}
else if (matchDomain('nzz.ch')) {
let regwall = document.querySelector('.dynamic-regwall');
removeDOMElement(regwall);
}
else if (matchDomain('rheinpfalz.de')) {
let url = window.location.href;
if (url.includes('reduced=true')) {
window.setTimeout(function () {
window.location.href = url.split('?')[0];
}, 500); // Delay (in milliseconds)
}
}
else if (matchDomain(['ruhrnachrichten.de'])) {
let url = window.location.href;
if (url.includes('?amp'))
amp_unhide_subscr_section();
}
else if (matchDomain(['westfalen-blatt.de', 'wn.de'])) {
let url = window.location.href;
if (url.includes('/amp/')) {
amp_unhide_subscr_section('amp-ad, amp-embed, section[class^="fp-ad"]');
} else {
let paywall = document.querySelector('.fp-article-paywall');
if (paywall) {
removeDOMElement(paywall);
window.location.href = url.replace('.de/', '.de/amp/');
}
}
}
else if ((domain = matchDomain(de_madsack_domains)) || document.querySelector('link[rel="preload"][href="https://static.rndtech.de/cmp/1.x.x.js"]')) {
let url = window.location.href;
if (!url.includes(domain + '/amp/')) {
let paidcontent_intro = document.querySelector('div.pdb-article-body-paidcontentintro');
if (paidcontent_intro) {
paidcontent_intro.classList.remove('pdb-article-body-paidcontentintro');
let json_script = document.querySelector('div.pdb-article > script[type="application/ld+json"]');
let json_text = JSON.parse(json_script.text).articleBody;
if (json_text) {
let pdb_richtext_field = document.querySelectorAll('div.pdb-richtext-field');
if (pdb_richtext_field[1])
pdb_richtext_field[1].innerText = json_text;
}
let paidcontent_reg = document.querySelector('div.pdb-article-paidcontent-registration');
removeDOMElement(paidcontent_reg);
}
} else {
amp_unhide_subscr_section('.pdb-ad-container');
}
}
else
csDone = true;
} else if (window.location.hostname.match(/\.(dk|fi|no|se)$/)) {//denmark/finland/norway/sweden
if (matchDomain(fi_alma_talent_domains)) {
let ads = document.querySelectorAll('div[class^="p2m385-"]');
removeDOMElement(...ads);
}
else if (matchDomain('hs.fi')) {
let url = window.location.href;
if (!url.includes('https://dynamic.hs.fi')) {
let iframe = document.querySelector('iframe[src^="https://dynamic.hs.fi/a/"]');
if (iframe && url.includes('.html')) {
window.setTimeout(function () {
window.location.href = iframe.src;
}, 500); // Delay (in milliseconds)
}
} else {
let paywall = document.querySelector('.paywall-container, .paywall-wrapper');
if (paywall && dompurify_loaded) {
let scripts = document.querySelectorAll('script');
let json_script;
for (let script of scripts) {
if (script.innerText.includes('window.__NUXT__='))
json_script = script;
continue;
}
let json_text;
if (json_script.innerHTML.includes('paywallComponents:['))
json_text = json_script.innerHTML.replace(/\r\n/g, '').split('amlData:[')[1].split('metaData')[0].split('paywallComponents:[')[1].slice(0, -4);
let main = document.querySelector('main');
if (main && json_text) {
let pars = json_text.split('{type:');
let type, value, slides, src, elem, img, caption, caption_text, par_html, par_text;
let parser = new DOMParser();
for (let par of pars) {
//console.log(par);
elem = '';
type = par.split(',')[0];
if (['a', 'i'].includes(type)) { // text
value = par.split('value:')[1].split('}')[0].replace(/(^"|"$)/g, '');
if (!value.includes('<p>'))
value = '<p>' + value + '</p>';
par_html = parser.parseFromString(DOMPurify.sanitize(value), 'text/html');
elem = par_html.querySelector('p');
} else if (['D', 'f', 'j', 'k'].includes(type)) { // quote
if (par.includes('text:') && par.includes(',position:')) {
value = par.split('text:')[1].split(',position:')[0].replace(/(^"|"$)/g, '');
elem = document.createElement('p');
elem.innerText = value;
elem.setAttribute('style', 'font-style: italic;');
}
} else if (['m', 'u'].includes(type)) { // authors
value = par.split('text:')[1].split(',role')[0].replace(/(^"|"$)/g, '');
if (value.length > 1) {
elem = document.createElement('p');
elem.innerText = value;
}
} else if (['e', 'h', 'y'].includes(type)) { // image
src = par.split('src:"')[1].split('",')[0];
if (!src.startsWith('http'))
src = 'https://arkku.mediadelivery.fi/img/468/' + src;
elem = document.createElement('p');
img = document.createElement('img');
img.setAttribute('src', src);
img.setAttribute('style', 'width:468px !important');
elem.appendChild(img);
if (par.includes('caption:')) {
caption = document.createElement('figcaption');
caption_text = par.split('caption:')[1].split('",')[0];
if (caption_text.length)
caption_text = caption_text.slice(1, caption_text.length - 1);
caption.innerText = caption_text;
elem.appendChild(caption);
}
} else if (['p', 'r'].includes(type)) { // slides
slides = par.split('src:');
elem = document.createElement('p');
for (let slide of slides) {
if (slide.includes('.jpg')) {
src = slide.split(',')[0].replace(/"/g, '');
if (!src.startsWith('http'))
src = 'https://arkku.mediadelivery.fi/img/468/' + src;
img = document.createElement('img');
img.setAttribute('src', src);
img.setAttribute('style', 'width:468px !important');
elem.appendChild(img);
caption = document.createElement('figcaption');
caption_text = slide.split('text:')[1].split(',"text-style"')[0];
if (caption_text.length)
caption_text = caption_text.slice(1, caption_text.length - 1);
par_html = parser.parseFromString('<div>' + DOMPurify.sanitize(caption_text) + '</div>', 'text/html');
elem.appendChild(par_html.querySelector('div'));
}
}
} else
false;//console.log('type: ' + type + ' par: ' + par);
if (elem) {
elem.setAttribute('class', 'article-body px-16 mb-24');
main.appendChild(elem);
}
}
main.appendChild(document.createElement('br'));
}
removeDOMElement(paywall);
}
}
}
else if (matchDomain('nyteknik.se')) {
// plus code in contentScript_once.js
let locked_article = document.querySelector('div.locked-article');
if (locked_article)
locked_article.classList.remove('locked-article');
}
else
csDone = true;
} else if (window.location.hostname.match(/\.(es|pt)$/) || matchDomain(['diariovasco.com', 'elconfidencial.com', 'elcorreo.com', 'elespanol.com', 'elpais.com', 'elperiodico.com', 'elperiodicomediterraneo.com', 'expansion.com', 'larioja.com', 'lavanguardia.com', 'levante-emv.com', 'marca.com', 'politicaexterior.com'])) {//spain/portugal
if (matchDomain('abc.es')) {
if (window.location.pathname.endsWith('_amp.html')) {
amp_unhide_access_hide('="result=\'ALLOW_ACCESS\'"', '', 'amp-ad, amp-embed');
premium_banner = document.querySelector('.cierre-suscripcion');
removeDOMElement(premium_banner);
}
}
else if (matchDomain('cmjornal.pt')) {
let paywall = document.querySelector('.bloqueio_exclusivos');
let amphtml = document.querySelector('link[rel="amphtml"]');
let url = window.location.href;
if (!url.includes('/amp/')) {
if (paywall && amphtml) {
removeDOMElement(paywall);
window.location.href = amphtml.href;
}
} else {
amp_unhide_access_hide('="subscriber"', '="NOT subscriber"', 'amp-ad, amp-embed, #flying-carpet-wrapper');
let amp_links = document.querySelectorAll('a[href^="https://www-cmjornal-pt.cdn.ampproject.org/c/s/"]');
for (let amp_link of amp_links)
amp_link.href = amp_link.href.replace('www-cmjornal-pt.cdn.ampproject.org/c/s/', '');
}
}
else if (matchDomain('elconfidencial.com')) {
let premium = document.querySelector('div.newsType__content--closed');
if (premium)
premium.classList.remove('newsType__content--closed');
}
else if (matchDomain('eldiario.es')) {
if (window.location.pathname.endsWith('.amp.html')) {
amp_unhide_access_hide('^="access"');
}
}
else if (matchDomain('elespanol.com')) {
if (window.location.pathname.endsWith('.amp.html')) {
amp_unhide_subscr_section('amp-ad, amp-embed');
} else {
let adverts = document.querySelectorAll('[id*="superior"], [class*="adv"]');
removeDOMElement(...adverts);
}
}
else if (matchDomain(es_unidad_domains)) {
let premium = document.querySelector('.ue-c-article__premium');
let url = window.location.href;
if (!window.location.hostname.startsWith('amp.')) {
if (premium) {
removeDOMElement(premium);
window.location.href = url.replace('/www.', '/amp.');
}
} else {
amp_unhide_access_hide('="authorized=true"', '="authorized!=true"');
amp_unhide_subscr_section('.advertising, amp-embed, amp-ad');
}
}
else if (matchDomain('elpais.com')) {
let url = window.location.href;
let login_register = document.querySelector('.login_register');
if (url.includes('.amp.html') || url.includes('?outputType=amp')) {
amp_unhide_access_hide('="success"', '="NOT success"');
removeDOMElement(login_register);
} else {
let counter = document.querySelector('#counterLayerDiv');
removeDOMElement(counter);
let video = document.querySelector('div.videoTop');
let amphtml = document.querySelector('link[rel="amphtml"]');
if ((login_register || video) && amphtml) {
removeDOMElement(login_register, video);
window.location.href = amphtml.href;
}
}
let paywall_offer = document.querySelector('.paywallOffer');
let ctn_closed_article = document.querySelector('#ctn_closed_article');
removeDOMElement(paywall_offer, ctn_closed_article);
}
else if (matchDomain('elperiodico.com')) {
let url = window.location.href;
if (!url.includes('amp.elperiodico.com')) {
let div_hidden = document.querySelector('div.closed');
if (div_hidden)
div_hidden.classList.remove('closed');
else {
let paywall = document.querySelector('.ep-masPeriodico-info-login');
removeDOMElement(paywall);
if (paywall)
window.location.href = url.replace('www.', 'amp.');
}
} else {
let not_logged = document.querySelector('.ep-masPeriodico-info-login');
if (not_logged) {
removeDOMElement(not_logged);
amp_unhide_access_hide('^="logged"', '^="NOT logged"');
}
window.setTimeout(function () {
let amp_img = document.querySelectorAll('amp-img > img');
for (let elem of amp_img) {
if (elem.src)
elem.src = elem.src.replace('amp.elperiodico.com/clip/', 'estaticos-cdn.elperiodico.com/clip/');
}
}, 3000); // Delay (in milliseconds)
}
}
else if (matchDomain(es_grupo_vocento_domains)) {
let url = window.location.href;
let content_exclusive_bg = document.querySelector('.content-exclusive-bg, #cierre_suscripcion, ev-engagement[group-name^="paywall-"]');
let amphtml = document.querySelector('link[rel="amphtml"]');
if (content_exclusive_bg && amphtml) {
removeDOMElement(content_exclusive_bg);
window.location.href = url.split('?')[0].replace('.html', '_amp.html');
} else if (url.includes('_amp.html')) {
let voc_advers = document.querySelectorAll('.voc-adver, amp-embed');
removeDOMElement(...voc_advers);
let container_wall_exclusive = document.querySelector('.container-wall-exclusive');
if (container_wall_exclusive) {
removeDOMElement(container_wall_exclusive);
amp_unhide_access_hide('="result=\'ALLOW_ACCESS\'"', '="result!=\'ALLOW_ACCESS\'"');
}
//lavozdigital.es
amp_unhide_subscr_section();
}
}
else if (matchDomain(es_epiberica_domains)) {
let truncated = document.querySelector('div.article-body--truncated');
if (truncated)
truncated.classList.remove('article-body--truncated');
window.setTimeout(function () {
let paywall = document.querySelector('div.paywall');
removeDOMElement(paywall);
}, 500); // Delay (in milliseconds)
if (window.location.href.includes('.amp.html')) {
amp_unhide_access_hide('="NOT access"', '="access"');
amp_unhide_access_hide('="FALSE"');
} else {
let div_hidden = document.querySelector('div.baldomero');
if (div_hidden)
div_hidden.classList.remove('baldomero');
}
}
else if (matchDomain('lavanguardia.com')) {
let paywall = document.querySelector('[class*="ev-open-modal-paywall"]');
let infinite_loading = document.querySelector('#infinite-loading');
removeDOMElement(paywall, infinite_loading);
}
else if (matchDomain('observador.pt')) {
let paywall = document.querySelector('.premium-article');
if (paywall)
paywall.classList.remove('premium-article');
let amp_ads = document.querySelectorAll('amp-ad');
removeDOMElement(... amp_ads)
}
else if (matchDomain('politicaexterior.com')) {
let paywall = document.querySelector('div[class^="paywall-"]');
if (paywall) {
let article = document.querySelector('div.entry-content-text');
let json = document.querySelector('script[type="application/ld+json"]:not([class]');
if (json) {
let json_text = JSON.parse(json.text).description.replace(/&nbsp;/g, '');
let article_new = document.createElement('div');
article_new.setAttribute('class', 'entry-content-text');
article_new.innerText = '\r\n' + json_text;
article.parentNode.replaceChild(article_new, article);
}
removeDOMElement(paywall);
}
}
else
csDone = true;
} else if (window.location.hostname.endsWith('.fr') || matchDomain(['bienpublic.com', 'journaldunet.com', 'la-croix.com', 'ledauphine.com', 'ledevoir.com', 'lesinrocks.com', 'lejsl.com', 'loeildelaphotographie.com', 'marianne.net', 'nouvelobs.com', 'parismatch.com', 'science-et-vie.com'].concat(fr_groupe_nice_matin_domains))) {//france
if (matchDomain('alternatives-economiques.fr')) {
window.setTimeout(function () {
let paywall = document.querySelector('#temp-paywall');
removeDOMElement(paywall);
let data_ae_poool = document.querySelector('div[data-ae-poool]');
if (data_ae_poool)
data_ae_poool.removeAttribute('style');
}, 500); // Delay (in milliseconds)
}
else if (matchDomain('atlantico.fr')) {
let paywall = document.querySelector('div.markup[class*="Paywall"]');
if (paywall)
paywall.setAttribute('class', 'markup');
}
else if (matchDomain('challenges.fr')) {
if (window.location.pathname.endsWith('.amp')) {
amp_unhide_access_hide('="paywall.access OR cha.access"', '="NOT (paywall.access OR cha.access)"');
} else {
let amorce = document.querySelector('.user-paying-amorce');
if (amorce)
amorce.setAttribute('style', 'display:none !important');
let content = document.querySelectorAll('.user-paying-content');
for (let elem of content)
elem.classList.remove('user-paying-content');
let paywall = document.querySelector('.temp-paywall');
removeDOMElement(paywall);
}
}
else if (matchDomain('charliehebdo.fr')) {
window.setTimeout(function () {
let paywalled_content = document.querySelector('div.ch-paywalled-content');