@ -5,6 +5,7 @@ var domain;
var csDone ;
var csDoneOnce ;
var dompurify _loaded = ( typeof DOMPurify === 'function' ) ;
var dompurify _options = { ADD _TAGS : [ 'amp-img' , 'iframe' , 'list' ] , ADD _ATTR : [ 'allow' , 'allowfullscreen' , 'frameborder' , 'itemprop' , 'layout' , 'target' ] } ;
var ar _grupo _clarin _domains = [ 'clarin.com' , 'lavoz.com.ar' , 'losandes.com.ar' ] ;
var be _groupe _ipm _domains = [ 'dhnet.be' , 'lalibre.be' , 'lavenir.net' ] ;
@ -86,7 +87,7 @@ if (bg2csData.ld_json && dompurify_loaded) {
}
if ( json _text ) {
let parser = new DOMParser ( ) ;
let doc = parser . parseFromString ( '<div style="margin: 25px 0px">' + DOMPurify . sanitize ( breakText ( json _text ) . replace ( /\n\n/g , '<br><br>' ) , { ADD _TAGS : [ 'iframe' ] , ADD _ATTR : [ 'frameborder' ] } ) + '</div>' , 'text/html' ) ;
let doc = parser . parseFromString ( '<div style="margin: 25px 0px">' + DOMPurify . sanitize ( breakText ( json _text ) . replace ( /\n\n/g , '<br><br>' ) , dompurify _options ) + '</div>' , 'text/html' ) ;
let article _new = doc . querySelector ( 'div' ) ;
if ( article _append || ! article . parentNode ) {
article . innerHTML = '' ;
@ -125,7 +126,7 @@ if (bg2csData.ld_json_next && dompurify_loaded) {
let json _text = parseHtmlEntities ( findKeyJson ( json , [ 'body' , 'content' , 'description' ] , 500 ) ) ;
if ( json _text ) {
let parser = new DOMParser ( ) ;
let doc = parser . parseFromString ( '<div>' + DOMPurify . sanitize ( json _text , { ADD _TAGS : [ 'iframe' ] , ADD _ATTR : [ 'frameborder' ] } ) + '</div>' , 'text/html' ) ;
let doc = parser . parseFromString ( '<div>' + DOMPurify . sanitize ( json _text , dompurify _options ) + '</div>' , 'text/html' ) ;
let article _new = doc . querySelector ( 'div' ) ;
if ( article _append || ! article . parentNode ) {
article . innerHTML = '' ;
@ -300,7 +301,7 @@ window.addEventListener('message', function (event) {
if ( data && article && dompurify _loaded && ! msg _once ) {
msg _once = true ;
let parser = new DOMParser ( ) ;
let doc = parser . parseFromString ( '<div>' + DOMPurify . sanitize ( data , { ADD _TAGS : [ 'iframe' ] , ADD _ATTR : [ 'frameborder' ] } ) + '</div>' , 'text/html' ) ;
let doc = parser . parseFromString ( '<div>' + DOMPurify . sanitize ( data , dompurify _options ) + '</div>' , 'text/html' ) ;
let article _new = doc . querySelector ( 'div' ) ;
if ( article _new ) {
article . innerHTML = '' ;
@ -696,7 +697,7 @@ else if (matchDomain(['beobachter.ch', 'handelszeitung.ch'])) {
let content _new = parser . parseFromString ( '<div>' + DOMPurify . sanitize ( par _elem . text ) + '</div>' , 'text/html' ) ;
sub _elem = content _new . querySelector ( 'div' ) ;
} else if ( par _elem . _ _typename === 'EmbedParagraph' && par _elem . embedCode ) {
let content _new = parser . parseFromString ( '<div>' + DOMPurify . sanitize ( par _elem . embedCode , { ADD _TAGS : [ 'iframe' ] , ADD _ATTR : [ 'frameborder' ] } ) + '</div>' , 'text/html' ) ;
let content _new = parser . parseFromString ( '<div>' + DOMPurify . sanitize ( par _elem . embedCode , dompurify _options ) + '</div>' , 'text/html' ) ;
sub _elem = content _new . querySelector ( 'div' ) ;
let iframe = sub _elem . querySelector ( 'iframe[width]' ) ;
if ( iframe ) {
@ -871,14 +872,7 @@ else if (matchDomain('faz.net')) {
else if ( matchDomain ( 'freiepresse.de' ) ) {
if ( window . location . pathname . includes ( '-artikel' ) ) {
let url = window . location . href ;
let paywall = document . querySelector ( 'div.article-teaser' ) ;
if ( paywall ) {
removeDOMElement ( paywall ) ;
csDoneOnce = true ;
let url _cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url . split ( '?' ) [ 0 ] ;
replaceDomElementExt ( url _cache , true , false , 'article' ) ;
}
window . setTimeout ( function ( ) {
let func _post = function ( ) {
let lazy _images = document . querySelectorAll ( 'picture.lazy' ) ;
for ( let elem of lazy _images ) {
elem . removeAttribute ( 'class' ) ;
@ -889,7 +883,8 @@ else if (matchDomain('freiepresse.de')) {
source . parentNode . replaceChild ( img _new , source ) ;
}
}
} , 1000 ) ;
}
getGoogleWebcache ( url , 'div.article-teaser' , '' , 'article' , func _post ) ;
}
}
@ -1079,36 +1074,24 @@ else if (matchDomain('kurier.at')) {
else if ( matchDomain ( 'letemps.ch' ) ) {
let url = window . location . href ;
let paywall = document . querySelector ( 'div.post-subscribe' ) ;
if ( paywall ) {
removeDOMElement ( paywall ) ;
csDoneOnce = true ;
let url _cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url . split ( '?' ) [ 0 ] ;
replaceDomElementExt ( url _cache , true , false , 'div.post-body-wrapper' ) ;
window . setTimeout ( function ( ) {
let lazy _images = document . querySelectorAll ( 'img.lazy[src="/placeholder.png"][data-src]' ) ;
for ( let elem of lazy _images ) {
elem . src = elem . getAttribute ( 'data-src' ) ;
elem . removeAttribute ( 'class' ) ;
}
let fade = document . querySelector ( 'div.post__content--faded' ) ;
if ( fade )
fade . classList . remove ( 'post__content--faded' ) ;
} , 1000 ) ;
let func _post = function ( ) {
let lazy _images = document . querySelectorAll ( 'img.lazy[src="/placeholder.png"][data-src]' ) ;
for ( let elem of lazy _images ) {
elem . src = elem . getAttribute ( 'data-src' ) ;
elem . removeAttribute ( 'class' ) ;
}
let fade = document . querySelector ( 'div.post__content--faded' ) ;
if ( fade )
fade . classList . remove ( 'post__content--faded' ) ;
}
getGoogleWebcache ( url , 'div.post-subscribe' , '' , 'div.post-body-wrapper' , func _post ) ;
let ads = document . querySelectorAll ( 'div.topad' ) ;
hideDOMElement ( ... ads ) ;
}
else if ( matchDomain ( [ 'mz.de' , 'volksstimme.de' ] ) ) {
let url = window . location . href ;
let paywall = document . querySelector ( 'div.fp-paywall' ) ;
if ( paywall ) {
removeDOMElement ( paywall ) ;
csDoneOnce = true ;
let url _cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url . split ( '?' ) [ 0 ] ;
replaceDomElementExt ( url _cache , true , false , 'div[data-t-name="Article"]' ) ;
}
getGoogleWebcache ( url , 'div.fp-paywall' , '' , 'div[data-t-name="Article"]' ) ;
}
else if ( matchDomain ( [ 'noz.de' , 'shz.de' , 'svz.de' ] ) ) {
@ -1192,13 +1175,12 @@ else if (matchDomain('profil.at')) {
else if ( matchDomain ( 'schwaebische.de' ) ) {
let url = window . location . href ;
let paywall = document . querySelector ( 'div > div.sve-paywall-wrapper_overlay' ) ;
let paywall _sel = 'div > div.sve-paywall-wrapper_overlay' ;
let paywall = document . querySelector ( paywall _sel ) ;
getGoogleWebcache ( url , paywall _sel , '' , 'div.article_body' ) ;
if ( paywall ) {
removeDOMElement ( paywall . parentNode ) ;
csDoneOnce = true ;
let url _cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url . split ( '?' ) [ 0 ] ;
replaceDomElementExt ( url _cache , true , false , 'div.article_body' ) ;
let body = document . querySelector ( 'body' ) ;
let body = document . querySelector ( 'body[style]' ) ;
if ( body )
body . removeAttribute ( 'style' ) ;
waitDOMAttribute ( 'body' , 'body' , 'style' , node => node . removeAttribute ( 'style' ) , true ) ;
@ -1216,13 +1198,7 @@ else if (matchDomain('schweizermonat.ch')) {
else if ( matchDomain ( 'sn.at' ) ) {
let url = window . location . href ;
let paywall = document . querySelector ( 'div.article-sections__paywall' ) ;
if ( paywall ) {
removeDOMElement ( paywall ) ;
csDoneOnce = true ;
let url _cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url . split ( '?' ) [ 0 ] ;
replaceDomElementExt ( url _cache , true , false , 'div.article-body-text' ) ;
}
getGoogleWebcache ( url , 'div.article-sections__paywall' , '' , 'div.article-body-text' ) ;
}
else if ( matchDomain ( 'spiegel.de' ) ) {
@ -1719,13 +1695,7 @@ else if (matchDomain('charliehebdo.fr')) {
else if ( matchDomain ( 'cieletespace.fr' ) ) {
let url = window . location . href ;
let paywall = document . querySelector ( 'div.article-content__subscribe' ) ;
if ( paywall ) {
removeDOMElement ( paywall ) ;
csDoneOnce = true ;
let url _cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url . split ( '?' ) [ 0 ] ;
replaceDomElementExt ( url _cache , true , false , 'div.article-content' ) ;
}
getGoogleWebcache ( url , 'div.article-content__subscribe' , '' , 'div.article-content' ) ;
}
else if ( matchDomain ( 'connaissancedesarts.com' ) ) {
@ -2817,13 +2787,7 @@ if (matchDomain('apollo-magazine.com')) {
else if ( matchDomain ( 'autocar.co.uk' ) ) {
let url = window . location . href ;
let paywall = document . querySelector ( 'div.ms-block, div.register-block' ) ;
if ( paywall ) {
removeDOMElement ( paywall ) ;
csDoneOnce = true ;
let url _cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url . split ( '?' ) [ 0 ] ;
replaceDomElementExt ( url _cache , true , false , 'div.content-wrapper' ) ;
}
getGoogleWebcache ( url , 'div.ms-block, div.register-block' , '' , 'div.content-wrapper' ) ;
}
else if ( matchDomain ( [ 'belfasttelegraph.co.uk' , 'independent.ie' ] ) ) {
@ -2955,20 +2919,14 @@ else if (matchDomain('businesspost.ie')) {
else if ( matchDomain ( 'citywire.com' ) ) {
let url = window . location . href ;
let paywall = document . querySelector ( 'div.locked-content.cw-article-body' ) ;
if ( paywall ) {
paywall . classList . remove ( 'locked-content' ) ;
csDoneOnce = true ;
let url _cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url . split ( '?' ) [ 0 ] ;
replaceDomElementExt ( url _cache , true , false , 'div.cw-article-body' ) ;
}
window . setTimeout ( function ( ) {
let func _post = function ( ) {
let banners = document . querySelectorAll ( 'div#lockedLoginPanel, div#lockedContentPlaceholder' ) ;
removeDOMElement ( ... banners ) ;
let article = document . querySelector ( 'div.cw-article-body' ) ;
if ( article )
removeDOMElement ( article . nextSibling ) ;
} , 1000 ) ;
}
getGoogleWebcache ( url , 'div.locked-content.cw-article-body' , { rm _class : 'locked-content' } , 'div.cw-article-body' , func _post ) ;
}
else if ( matchDomain ( 'fnlondon.com' ) ) {
@ -3011,13 +2969,7 @@ else if (matchDomain('independent.co.uk')) {
else if ( matchDomain ( 'prospectmagazine.co.uk' ) ) {
let url = window . location . href ;
let paywall = document . querySelector ( 'div.paywall_overlay_blend, div.paywall' ) ;
if ( paywall ) {
removeDOMElement ( paywall ) ;
csDoneOnce = true ;
let url _cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url . split ( '?' ) [ 0 ] ;
replaceDomElementExt ( url _cache , true , false , 'main' ) ;
}
getGoogleWebcache ( url , 'div.paywall_overlay_blend, div.paywall' , '' , 'main' ) ;
window . setTimeout ( function ( ) {
let ads = document . querySelectorAll ( '.ad-banner, .advert' ) ;
hideDOMElement ( ... ads ) ;
@ -3201,9 +3153,16 @@ else if (matchDomain('thetimes.co.uk')) {
let paywall = document . querySelector ( 'div#paywall-portal-article-footer' ) ;
if ( paywall && ! url . includes ( '?shareToken=' ) ) {
removeDOMElement ( paywall ) ;
let article = document . querySelector ( 'article[class^="responsive__BodyContainer"]' ) ;
if ( article )
article . firstChild . before ( archiveLink ( url ) ) ;
let url _archive = 'https://' + archiveRandomDomain ( ) + '/' + url ;
replaceDomElementExt ( url _archive , true , false , 'article:not([id])' ) ;
window . setTimeout ( function ( ) {
let headings = document . querySelectorAll ( 'div > div[role="heading"]' ) ;
for ( let elem of headings )
elem . parentNode . style [ 'margin-top' ] = '50px' ;
let image _boxes = document . querySelectorAll ( 'div[id*="."][style]' ) ;
for ( let elem of image _boxes )
elem . style [ 'margin-bottom' ] = '50px' ;
} , 1500 ) ;
for ( let n = 0 ; n < 5 ; n ++ ) {
window . setTimeout ( function ( ) {
let page _scroll = document . querySelectorAll ( 'html, body' ) ;
@ -3551,13 +3510,7 @@ else if (matchDomain('americanbanker.com') || matchDomain(usa_arizent_custom_dom
else if ( matchDomain ( 'arkansasonline.com' ) ) {
let url = window . location . href ;
let paywall = document . querySelector ( 'div.bee-page-container' ) ;
if ( paywall ) {
removeDOMElement ( paywall ) ;
csDoneOnce = true ;
let url _cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url . split ( '?' ) [ 0 ] ;
replaceDomElementExt ( url _cache , true , false , 'div.article__body' ) ;
}
getGoogleWebcache ( url , 'div.bee-page-container' , '' , 'div.article__body' ) ;
}
else if ( matchDomain ( 'artnet.com' ) ) {
@ -3814,15 +3767,12 @@ else if (matchDomain('cnbc.com')) {
else if ( matchDomain ( 'columbian.com' ) ) {
let url = window . location . href ;
let paywall = document . querySelector ( 'div#inline-paywall' ) ;
if ( paywall ) {
let func _post = function ( ) {
let modal = document . querySelector ( 'div.modal' ) ;
let fade = document . querySelector ( 'div[style*="background-image: linear-gradient"]' ) ;
removeDOMElement ( paywall , modal , fade ) ;
csDoneOnce = true ;
let url _cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url . split ( '?' ) [ 0 ] ;
replaceDomElementExt ( url _cache , true , false , 'div[itemprop="articleBody"]' ) ;
removeDOMElement ( modal , fade ) ;
}
getGoogleWebcache ( url , 'div#inline-paywall' , '' , 'div[itemprop="articleBody"]' , func _post ) ;
}
else if ( matchDomain ( 'csmonitor.com' ) ) {
@ -3858,7 +3808,7 @@ else if (matchDomain('defector.com')) {
if ( response . ok ) {
response . text ( ) . then ( html => {
let parser = new DOMParser ( ) ;
let doc = parser . parseFromString ( DOMPurify . sanitize ( html , { ADD _TAGS : [ 'iframe' ] , ADD _ATTR : [ 'allow' , 'allowfullscreen' , 'frameborder' , 'target' ] } ) , 'text/html' ) ;
let doc = parser . parseFromString ( DOMPurify . sanitize ( html , dompurify _options ) , 'text/html' ) ;
let article _new = doc . querySelector ( article _sel ) ;
article . parentNode . replaceChild ( article _new , article ) ;
} ) ;
@ -3896,7 +3846,7 @@ else if (matchDomain('economictimes.com')) {
let content = document . querySelector ( '.paywall[style="display:none;"]' ) ;
if ( content ) {
let parser = new DOMParser ( ) ;
let doc = parser . parseFromString ( '<div style="margin: 20px 0px;">' + DOMPurify . sanitize ( content . innerText , { ADD _TAGS : [ 'iframe' ] , ADD _ATTR : [ 'frameborder' ] } ) + '</div>' , 'text/html' ) ;
let doc = parser . parseFromString ( '<div style="margin: 20px 0px;">' + DOMPurify . sanitize ( content . innerText , dompurify _options ) + '</div>' , 'text/html' ) ;
let content _new = doc . querySelector ( 'div' ) ;
if ( content _new && content . parentNode )
content . parentNode . replaceChild ( content _new , content ) ;
@ -4477,13 +4427,7 @@ else if (matchDomain('nautil.us')) {
else if ( matchDomain ( 'newleftreview.org' ) ) {
window . setTimeout ( function ( ) {
let url = window . location . href ;
let paywall = document . querySelector ( 'div.promo-wrapper' ) ;
if ( paywall ) {
removeDOMElement ( paywall ) ;
csDoneOnce = true ;
let url _cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url . split ( '?' ) [ 0 ] ;
replaceDomElementExt ( url _cache , true , false , 'div.article-page' ) ;
}
getGoogleWebcache ( url , 'div.promo-wrapper' , '' , 'div.article-page' ) ;
} , 500 ) ;
}
@ -4497,14 +4441,7 @@ else if (matchDomain('newrepublic.com')) {
else if ( matchDomain ( 'newscientist.com' ) ) {
let url = window . location . href ;
let paywall = document . querySelector ( 'section#subscription-barrier' ) ;
if ( paywall ) {
removeDOMElement ( paywall ) ;
csDoneOnce = true ;
let url _cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url . split ( '?' ) [ 0 ] ;
replaceDomElementExt ( url _cache , true , false , 'div.article-body, article' ) ;
}
window . setTimeout ( function ( ) {
func _post = function ( ) {
let lazy _images = document . querySelectorAll ( 'img.lazyload[data-src]:not([src])' ) ;
for ( let elem of lazy _images )
elem . src = elem . getAttribute ( 'data-src' ) . split ( '?' ) [ 0 ] + '?width=800' ;
@ -4520,6 +4457,9 @@ else if (matchDomain('newscientist.com')) {
removeDOMElement ( break _post ) ;
}
}
}
getGoogleWebcache ( url , 'section#subscription-barrier' , '' , 'div.article-body, article' , func _post ) ;
window . setTimeout ( function ( ) {
let ads = document . querySelectorAll ( 'div[class*="Advert"]' ) ;
hideDOMElement ( ... ads ) ;
} , 1500 ) ;
@ -4739,13 +4679,7 @@ else if (matchDomain('slideshare.net')) {
else if ( matchDomain ( 'sloanreview.mit.edu' ) ) {
let url = window . location . href ;
let paywall = document . querySelector ( 'body.is-paywall' ) ;
if ( paywall ) {
paywall . classList . remove ( 'is-paywall' ) ;
csDoneOnce = true ;
let url _cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url . split ( '?' ) [ 0 ] ;
replaceDomElementExt ( url _cache , true , false , 'div#article-content' ) ;
}
getGoogleWebcache ( url , 'body.is-paywall' , { rm _class : 'is-paywall' } , 'div#article-content' ) ;
}
else if ( matchDomain ( 'sofrep.com' ) ) {
@ -4824,7 +4758,7 @@ else if (matchDomain('stereogum.com')) {
let content = document . querySelector ( 'div.article__content div.text-block__inner' ) ;
if ( json _text && content ) {
let parser = new DOMParser ( ) ;
let doc = parser . parseFromString ( '<div>' + DOMPurify . sanitize ( json _text , { ADD _TAGS : [ 'iframe' ] , ADD _ATTR : [ 'frameborder' , 'allow' , 'allowfullscreen' ] } ) + '</div>' , 'text/html' ) ;
let doc = parser . parseFromString ( '<div>' + DOMPurify . sanitize ( json _text , dompurify _options ) + '</div>' , 'text/html' ) ;
let content _new = doc . querySelector ( 'div' ) ;
content . innerHTML = '' ;
content . appendChild ( content _new ) ;
@ -5491,19 +5425,18 @@ else if (matchDomain(no_nhst_media_domains)) {
else if ( matchDomain ( uk _incisive _media _domains ) ) {
let url = window . location . href ;
let paywall = document . querySelector ( 'div#d-wrapper' ) ;
let paywall _sel = 'div#d-wrapper' ;
let paywall = document . querySelector ( paywall _sel ) ;
if ( paywall ) {
removeDOMElement ( paywall ) ;
csDoneOnce = true ;
let live _blog = document . querySelector ( 'head > meta[name="description"][content^="In this live blog"]' ) ;
let article _sel = 'div.article-content' ;
let article = document . querySelector ( article _sel ) ;
if ( article ) {
if ( live _blog ) {
removeDOMElement ( paywall ) ;
article . firstChild . before ( googleWebcacheLink ( url ) ) ;
} else {
let url _cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url . split ( '?' ) [ 0 ] ;
replaceDomElementExt ( url _cache , true , false , article _sel ) ;
getGoogleWebcache ( url , 'div#d-wrapper' , '' , article _sel ) ;
}
}
}
@ -5898,11 +5831,43 @@ function blockJsReferrer() {
}
}
function clearPaywall ( paywall , paywall _action ) {
if ( paywall ) {
if ( ! paywall _action )
removeDOMElement ( ... paywall ) ;
else {
for ( let elem of paywall ) {
if ( paywall _action . rm _class )
elem . classList . remove ( paywall _action . rm _class ) ;
else if ( paywall _action . rm _attrib )
elem . removeAttribute ( paywall _action . rm _attrib ) ;
}
}
}
}
function getGoogleWebcache ( url , paywall _sel , paywall _action = '' , article _sel , func _post = '' , article _new _sel = article _sel ) {
let url _cache = 'https://webcache.googleusercontent.com/search?q=cache:' + url . split ( '?' ) [ 0 ] ;
let paywall = document . querySelectorAll ( paywall _sel ) ;
if ( paywall . length ) {
clearPaywall ( paywall , paywall _action ) ;
csDoneOnce = true ;
replaceDomElementExt ( url _cache , true , false , article _sel , '' , article _new _sel ) ;
if ( func _post ) {
window . setTimeout ( function ( ) {
func _post ( ) ;
} , 1500 ) ;
}
}
}
function replaceDomElementExt ( url , proxy , base64 , selector , text _fail = '' , selector _source = selector ) {
if ( proxy ) {
if ( ! text _fail ) {
if ( url . includes ( 'webcache.googleusercontent.com' ) )
text _fail = 'BPC > failed to load from Google webcache: '
if ( url . startsWith ( 'https://webcache.googleusercontent.com' ) )
text _fail = 'BPC > failed to load from Google webcache:\r\n' ;
else if ( url . startsWith ( 'https://archive.' ) )
text _fail = 'BPC > Try for full article text (no need to report issue for external site):\r\n' ;
}
ext _api . runtime . sendMessage ( { request : 'getExtSrc' , data : { url : url , selector : selector , selector _source : selector _source , base64 : base64 , text _fail : text _fail } } ) ;
} else {
@ -5936,13 +5901,28 @@ function replaceDomElementExtSrc(url, html, proxy, base64, selector, text_fail =
}
let parser = new DOMParser ( ) ;
window . setTimeout ( function ( ) {
let doc = parser . parseFromString ( DOMPurify . sanitize ( html , { ADD _ATTR : [ 'frameborder' , 'layout' , 'itemprop' ] , ADD _TAGS : [ 'amp-img' , 'iframe' ] } ) , 'text/html' ) ;
//console.log(DOMPurify.removed);
let article _new = doc . querySelector ( selector _source ) ;
if ( article _new ) {
if ( article && article . parentNode )
article . parentNode . replaceChild ( article _new , article ) ;
}
if ( url . startsWith ( 'https://archive.' ) ) {
let domain _archive = url . match ( /^https:\/\/(archive\.\w{2})/ ) [ 1 ] ;
let pathname = new URL ( url ) . pathname ;
html = html . replace ( new RegExp ( 'https:\\/\\/' + domain _archive . replace ( '.' , '\\.' ) + '\\/o\\/\\w+\\/' , 'g' ) , '' ) . replace ( new RegExp ( "(src=\"|background-image:url\\(')" + pathname . replace ( '/' , '\\/' ) , 'g' ) , "$1" + 'https://' + domain _archive + pathname ) ;
}
let doc = parser . parseFromString ( DOMPurify . sanitize ( html , dompurify _options ) , 'text/html' ) ;
//console.log(DOMPurify.removed);
let article _new = doc . querySelector ( selector _source ) ;
if ( article _new ) {
if ( article && article . parentNode ) {
if ( url . startsWith ( 'https://archive.' ) ) {
article _new . firstChild . before ( archiveLink _renew ( window . location . href ) ) ;
article _new . firstChild . before ( archiveLink ( window . location . href , 'BPC > Try when layout issues (no need to report issue for external site):\r\n' ) ) ;
window . setTimeout ( function ( ) {
let targets = document . querySelectorAll ( 'a[target="_blank"][href^="https://' + window . location . hostname + '"]' ) ;
for ( let elem of targets )
elem . removeAttribute ( 'target' ) ;
} , 1500 ) ;
}
article . parentNode . replaceChild ( article _new , article ) ;
}
}
} , 200 ) ;
} else {
replaceTextFail ( url , article , proxy , text _fail ) ;
@ -6010,14 +5990,7 @@ function amp_redirect(paywall_sel, paywall_action = '', amp_url = '') {
if ( ! amphtml && amp _url )
amphtml = { href : amp _url } ;
if ( paywall && amphtml ) {
if ( ! paywall _action )
removeDOMElement ( paywall ) ;
else {
if ( paywall _action . rm _class )
paywall . classList . remove ( paywall _action . rm _class ) ;
else if ( paywall _action . rm _attrib )
paywall . removeAttribute ( paywall _action . rm _attrib ) ;
}
clearPaywall ( paywall , paywall _action ) ;
amp _redirect _not _loop ( amphtml ) ;
}
}
@ -6065,8 +6038,18 @@ function refreshCurrentTab_bg() {
ext _api . runtime . sendMessage ( { request : 'refreshCurrentTab' } ) ;
}
function archiveRandomDomain ( ) {
let tld _array = [ 'fo' , 'is' , 'li' , 'md' , 'ph' , 'vn' ] ;
let tld = tld _array [ randomInt ( 6 ) ] ;
return 'archive.' + tld ;
}
function archiveLink ( url , text _fail = 'BPC > Try for full article text (no need to report issue for external site):\r\n' ) {
return externalLink ( [ 'archive.today' , 'archive.is' ] , 'https://{domain}?run=1&url={url}' , url , text _fail ) ;
return externalLink ( [ 'archive.today' , archiveRandomDomain ( ) ] , 'https://{domain}?run=1&url={url}' , url , text _fail ) ;
}
function archiveLink _renew ( url , text _fail = 'BPC > Only use to renew if text is incomplete or updated:\r\n' ) {
return externalLink ( [ archiveRandomDomain ( ) ] , 'https://{domain}?renew=1&url={url}' , url , text _fail ) ;
}
function googleWebcacheLink ( url , text _fail = 'BPC > Try for full article text:\r\n' ) {
@ -6210,7 +6193,7 @@ function getJsonUrlAdd(json_text, article, art_options = {}) {
json _text = art _options . func _text ( json _text ) ;
}
let parser = new DOMParser ( ) ;
let doc = parser . parseFromString ( '<' + art _type + art _attrib + '>' + DOMPurify . sanitize ( json _text , { ADD _TAGS : [ 'iframe' ] , ADD _ATTR : [ 'frameborder' ] } ) + '</' + art _type + '>' , 'text/html' ) ;
let doc = parser . parseFromString ( '<' + art _type + art _attrib + '>' + DOMPurify . sanitize ( json _text , dompurify _options ) + '</' + art _type + '>' , 'text/html' ) ;
let article _new = doc . querySelector ( art _type ) ;
if ( art _options . art _append || ! article . parentNode ) {
if ( ! art _options . art _hold )
@ -6224,16 +6207,7 @@ function getJsonUrl(paywall_sel, paywall_action = '', article_sel, art_options =
let paywall = document . querySelectorAll ( paywall _sel ) ;
let article = document . querySelector ( article _sel ) ;
if ( paywall . length && article && dompurify _loaded ) {
if ( ! paywall _action )
removeDOMElement ( ... paywall ) ;
else {
for ( let elem of paywall ) {
if ( paywall _action . rm _class )
elem . classList . remove ( paywall _action . rm _class ) ;
else if ( paywall _action . rm _attrib )
elem . removeAttribute ( paywall _action . rm _attrib ) ;
}
}
clearPaywall ( paywall , paywall _action ) ;
getJsonUrlText ( article , ( json _text , article ) => {
if ( json _text && article )
getJsonUrlAdd ( json _text , article , art _options ) ;