Fix Bloomberg (xhr)

This commit is contained in:
magnolia1234 2023-07-27 17:14:28 +02:00
parent 03325566a7
commit 57782b75e4
6 changed files with 14 additions and 192 deletions

View file

@ -4,6 +4,7 @@ Updates (install signed xpi-file): https://gitlab.com/magnolia1234/bypass-paywal
Post-release Post-release
Add Ruhr Nachrichten (+ Media Group Westfalen; opt-in to custom sites) 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 El Diario Vasco (mobile amp-redirect)
Fix New Scientist (regwall) Fix New Scientist (regwall)
Fix Star Tribune (mobile) Fix Star Tribune (mobile)

View file

@ -3331,194 +3331,10 @@ else if (matchDomain('billboard.com')) {
} }
else if (matchDomain('bloomberg.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 paywall = document.querySelectorAll('div[id^="fortress-"]');
let leaderboard = document.querySelector('div[id^="leaderboard"], div[class^="leaderboard"], div.canopy-container'); let leaderboard = document.querySelector('div[id^="leaderboard"], div[class^="leaderboard"], div.canopy-container');
let noscroll = document.querySelector('body[data-paywall-overlay-status]'); let ads = document.querySelectorAll('div[data-ad-status], div.dvz-v0-ad, div[class^="FullWidthAd_"]');
if (noscroll) hideDOMElement(...paywall, leaderboard, ...ads);
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('<div class="' + article_class + '">' + DOMPurify.sanitize(json_text, {ADD_TAGS: ['iframe', 'script']}) + '</div>', 'text/html');
let article_new = doc.querySelector('div');
if (article_new) {
article.parentNode.replaceChild(article_new, article);
let teaser_body = document.querySelector('div.body-content[class*="teaser-content_"]');
removeDOMElement(teaser_body);
let thirdparty_embed = document.querySelector('div.thirdparty-embed__container[style*="height: 0;"]');
if (thirdparty_embed)
thirdparty_embed.setAttribute('style', 'height: 550px !important;');
}
}
}
}
}
}
}
}
window.sessionStorage.clear();
if (window.location.pathname.startsWith('/live/')) { if (window.location.pathname.startsWith('/live/')) {
setInterval(function () { setInterval(function () {
window.localStorage.clear(); window.localStorage.clear();

View file

@ -769,5 +769,5 @@
"*://*.wyleex.com/*", "*://*.wyleex.com/*",
"*://webcache.googleusercontent.com/*" "*://webcache.googleusercontent.com/*"
], ],
"version": "3.2.6.4" "version": "3.2.6.5"
} }

View file

@ -246,9 +246,8 @@ var defaultSites = {
}, },
"Bloomberg": { "Bloomberg": {
domain: "bloomberg.com", domain: "bloomberg.com",
block_regex: /(\.tinypass\.com\/|assets\.bwbx\.io\/s\d\/(fence\/plug-client|javelin\/.+\/transporter)\/)/, allow_cookies: 1,
cs_dompurify: 1, block_regex: /\.cm\.bloomberg\.com\//
remove_cookies_select_drop: ["gatehouse_id"]
}, },
"Bloomberg Adria": { "Bloomberg Adria": {
domain: "bloombergadria.com", domain: "bloombergadria.com",

View file

@ -27,6 +27,12 @@
"allow_cookies": 1, "allow_cookies": 1,
"block_regex": "\\.auto-motor-und-sport\\.de\\/thenewsbar\\/static\\/pw\\.js" "block_regex": "\\.auto-motor-und-sport\\.de\\/thenewsbar\\/static\\/pw\\.js"
}, },
"Bloomberg": {
"domain": "bloomberg.com",
"allow_cookies": 1,
"block_regex": "\\.cm\\.bloomberg\\.com",
"upd_version": "3.2.6.5"
},
"Business Standard": { "Business Standard": {
"domain": "business-standard.com", "domain": "business-standard.com",
"allow_cookies": 1, "allow_cookies": 1,

View file

@ -2,8 +2,8 @@
"addons": { "addons": {
"magnolia@12.34": { "magnolia@12.34": {
"updates": [ "updates": [
{ "version": "3.2.5.0", { "version": "3.2.6.0",
"update_link": "https://gitlab.com/magnolia1234/bpc-uploads/-/raw/master/bypass_paywalls_clean-3.2.5.0.xpi" } "update_link": "https://gitlab.com/magnolia1234/bpc-uploads/-/raw/master/bypass_paywalls_clean-3.2.6.0.xpi" }
] ]
} }
} }