diff --git a/changelog.txt b/changelog.txt index d8fe09a..ccddb58 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,6 +4,7 @@ Updates (install signed xpi-file): https://gitlab.com/magnolia1234/bypass-paywal Post-release Add Ruhr Nachrichten (+ Media Group Westfalen; opt-in to custom sites) +Fix Bloomberg (xhr; disable Dark Reader) Fix El Diario Vasco (mobile amp-redirect) Fix New Scientist (regwall) Fix Star Tribune (mobile) diff --git a/contentScript.js b/contentScript.js index f36ef78..ff7ccf0 100644 --- a/contentScript.js +++ b/contentScript.js @@ -3331,194 +3331,10 @@ else if (matchDomain('billboard.com')) { } else if (matchDomain('bloomberg.com')) { - function bloomberg_noscroll(node) { - node.removeAttribute('data-paywall-overlay-status'); - } - waitDOMElement('div[id^="fortress-"]', 'DIV', removeDOMElement, true); - waitDOMAttribute('body', 'BODY', 'data-paywall-overlay-status', bloomberg_noscroll, true); let paywall = document.querySelectorAll('div[id^="fortress-"]'); let leaderboard = document.querySelector('div[id^="leaderboard"], div[class^="leaderboard"], div.canopy-container'); - let noscroll = document.querySelector('body[data-paywall-overlay-status]'); - if (noscroll) - noscroll.removeAttribute('data-paywall-overlay-status'); - hideDOMElement(...paywall, leaderboard); - let url = window.location.href; - if (url.match(/s\/\d{4}-/)) { - let page_ad = document.querySelectorAll('div.page-ad, div[data-ad-placeholder], div[class*="-ad-top"]'); - let reg_ui_client = document.querySelector('div#reg-ui-client'); - hideDOMElement(...page_ad, reg_ui_client); - let hidden_images = document.querySelectorAll('img.lazy-img__image[src][data-native-src]'); - for (let hidden_image of hidden_images) { - if (hidden_image.src.match(/\/(60|150)x-1\.(png|jpg)$/)) - hidden_image.setAttribute('src', hidden_image.getAttribute('data-native-src')); - hidden_image.style.filter = 'none'; - } - let hidden_charts = document.querySelectorAll('div[data-toaster-id][data-src]'); - for (let hidden_chart of hidden_charts) { - let elem = document.createElement('iframe'); - Object.assign(elem, { - src: hidden_chart.getAttribute('data-src'), - frameborder: 0, - height: hidden_chart.getAttribute('style').replace('min-height: ', ''), - scrolling: 'no' - }); - hidden_chart.parentNode.replaceChild(elem, hidden_chart); - } - let blur = document.querySelector('div.blur[style]'); - if (blur) { - blur.classList.remove('blur'); - blur.removeAttribute('style'); - } - let main_column = document.querySelector('div[class*="main-column__"]'); - if (main_column) - main_column.style = '-webkit-mask-image: none !important; mask-image: none !important;'; - let shimmering_content = document.querySelectorAll('div.shimmering-text'); - removeDOMElement(...shimmering_content); - let body_transparent = document.querySelector('main div[class*="nearly-transparent-text-blur"]'); - let article_blur = document.querySelector('main div[class^="styles_articleBlur__"]'); - if ((body_transparent || article_blur) && dompurify_loaded) { - if (body_transparent) - removeClassesByPrefix(body_transparent, 'nearly-transparent-text-blur'); - if (article_blur) - article_blur.removeAttribute('class'); - let articles = document.querySelectorAll('article[id], article[data-story-id]'); - if (articles && articles.length < 2) { - let json_script = document.querySelector('script[data-component-props="ArticleBody"], script[data-component-props="FeatureBody"]'); - let json_next_script = document.querySelector('script#__NEXT_DATA__'); - if (json_next_script) { - let json = JSON.parse(json_next_script.text); - let json_pars = json.props.pageProps.story.body.content; - let article_par = document.querySelector('div > p[class^="Paragraph_text-"]'); - let article; - if (article_par) { - let par_class = article_par.getAttribute('class'); - article = article_par.parentNode; - function attach_hyperlink(item_text, item_href, elem) { - let sub_elem = document.createElement('a'); - sub_elem.innerText = item_text; - sub_elem.href = item_href; - sub_elem.style = 'text-decoration: underline;'; - if (!item_href.startsWith('https://www.bloomberg.com')) - sub_elem.target = '_blank'; - elem.appendChild(sub_elem); - } - function attach_list(content, elem) { - let ul = document.createElement('ul'); - ul.setAttribute('style', 'list-style-type: disc; padding: 5px;'); - for (let item of content) { - if (item.type === 'listItem') { - let li = document.createElement('li'); - for (let list_item of item.content) { - if (list_item.type === 'text') { - if (list_item.value) { - li.appendChild(document.createTextNode(list_item.value)); - } - } else if (list_item.type === 'list') { - if (list_item.content) - false; //attach_list(list_item.content, li); - } else if (!['entity'].includes(list_item.type)) - console.log(list_item); - } - ul.appendChild(li); - } - } - elem.appendChild(ul); - } - for (let par of json_pars) { - let elem = document.createElement('p'); - elem.setAttribute('class', par_class); - if (['heading', 'paragraph'].includes(par.type)) { - for (let item of par.content) { - if (item.type === 'text' && item.value) { - elem.appendChild(document.createTextNode(item.value)); - } else if (item.type === 'link' && item.data && item.data.href) { - if (item.content && item.content[0] && item.content[0].value) - attach_hyperlink(item.content[0].value, item.data.href, elem); - } else if (item.type === 'entity') { - if (item.content && item.content[0] && item.content[0].value) { - if (['person', 'security'].includes(item.subType)) { - elem.appendChild(document.createTextNode(item.content[0].value)); - } else if (item.subType === 'story') { - if (item.data && item.data.link && item.data.link.destination && item.data.link.destination.web) { - attach_hyperlink(item.content[0].value, item.data.link.destination.web, elem); - } - } else - console.log(item); - } - } else - console.log(item); - } - } else if (par.type === 'quote' && par.content) { - for (let item of par.content) { - if (item.type === 'paragraph' && item.content && item.content[0] && item.content[0].value) { - elem.appendChild(document.createTextNode(item.content[0].value + ' ')); - } - } - elem.setAttribute('style', 'font-style: italic;'); - } else if (par.type === 'media' && par.subType === 'chart') { - if (par.data && par.data.chart) { - let figure = document.createElement('figure'); - if (par.data.attachment && par.data.attachment.title) - figure.appendChild(document.createTextNode(par.data.attachment.title)); - let img = document.createElement('img'); - img.src = par.data.chart.fallback; - figure.appendChild(img); - if (par.data.attachment && (par.data.attachment.source || par.data.attachment.footnote)) { - let caption = document.createElement('figcaption'); - caption.innerText = par.data.attachment.source + '\r\n' + par.data.attachment.footnote; - figure.appendChild(caption); - } - elem.appendChild(figure); - } - } else if (par.type === 'list' && par.content) { - attach_list(par.content, elem); - } else if (!['ad', 'inline-newsletter', 'inline-recirc', 'tabularData'].includes(par.type)) - console.log(par); - if (elem.hasChildNodes) - article.appendChild(elem); - } - } - } else if (json_script) { - let json = JSON.parse(json_script.text); - if (json) { - let json_text; - if (json.body) - json_text = json.body; - else if (json.story && json.story.body) - json_text = json.story.body; - if (json_text) { - removeDOMElement(json_script); - let article = document.querySelector('div.body-copy-v2:not(.art_done)'); - let article_class = 'body-copy-v2'; - if (!article) { - article = document.querySelector('div.body-copy:not(.art_done)'); - article_class = 'body-copy'; - } - if (!article) { - article = document.querySelector('div.body-content:not(.art_done)'); - article_class = 'body-content'; - } - if (article) { - article_class += ' art_done'; - let parser = new DOMParser(); - let doc = parser.parseFromString('