diff --git a/src/js/background.js b/src/js/background.js index c8ef2f9..45c2bdd 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -1,7 +1,7 @@ 'use strict'; const restrictions = { - 'barrons.com': /.+barrons\.com\/articles\/.+/, + 'barrons.com': /.+barrons\.com\/(amp\/)?article(s)?\/.+/, 'economist.com': /.+economist\.com\/.+\/\d{1,4}\/\d{1,2}\/\d{2}\/.+/, 'seekingalpha.com': /.+seekingalpha\.com\/article\/.+/ }; @@ -180,7 +180,8 @@ const blockedRegexes = { 'thenation.com': /thenation\.com\/.+\/paywall-script\.php/, 'thewrap.com': /thewrap\.com\/.+\/wallkit\.js/, 'wsj.com': /cdn\.ampproject\.org\/v\d\/amp-access-.+\.js/, - 'historyextra.com': /.+\.evolok\.net\/.+\/authorize\/.+/ + 'historyextra.com': /.+\.evolok\.net\/.+\/authorize\/.+/, + 'barrons.com': /cdn\.ampproject\.org\/v\d\/amp-access-.+\.js/ }; // Allowed external scripts diff --git a/src/js/contentScript.js b/src/js/contentScript.js index fd29a12..92a986f 100644 --- a/src/js/contentScript.js +++ b/src/js/contentScript.js @@ -306,6 +306,27 @@ if (matchDomain('rep.repubblica.it')) { window.location.href = window.location.href + '/amp'; } }, 500); +} else if (matchDomain('barrons.com')) { + document.addEventListener('DOMContentLoaded', () => { + const bodyContinuous = document.querySelector('body.is-continuous'); + const snippet = document.querySelector('meta[content="snippet"]'); + if (bodyContinuous && snippet) { + window.location.href = window.location.href.replace('barrons.com', 'barrons.com/amp'); + } + }); + if (!window.location.href.includes('barrons.com/amp/')) { + let href = ''; + const signinLinks = document.querySelectorAll('a.primary-button--link'); + for (const signinLink of signinLinks) { + href = signinLink.href; + if (href.includes('target=')) { + href = href.split('target')[1].split('%3F')[0]; + href = href.replace('=', '').replace('%3A', ':').replace(/%2F/g, '/'); + signinLink.href = href; + signinLink.text = 'Click'; + } + } + } } function matchDomain (domains) {