Add AMP redirect for barrons.com

This commit is contained in:
Adam 2020-06-28 15:34:11 -07:00
parent 596d85fcea
commit 58b60f03f0
2 changed files with 24 additions and 2 deletions

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
const restrictions = { 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}\/.+/, 'economist.com': /.+economist\.com\/.+\/\d{1,4}\/\d{1,2}\/\d{2}\/.+/,
'seekingalpha.com': /.+seekingalpha\.com\/article\/.+/ 'seekingalpha.com': /.+seekingalpha\.com\/article\/.+/
}; };
@ -180,7 +180,8 @@ const blockedRegexes = {
'thenation.com': /thenation\.com\/.+\/paywall-script\.php/, 'thenation.com': /thenation\.com\/.+\/paywall-script\.php/,
'thewrap.com': /thewrap\.com\/.+\/wallkit\.js/, 'thewrap.com': /thewrap\.com\/.+\/wallkit\.js/,
'wsj.com': /cdn\.ampproject\.org\/v\d\/amp-access-.+\.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 // Allowed external scripts

View File

@ -306,6 +306,27 @@ if (matchDomain('rep.repubblica.it')) {
window.location.href = window.location.href + '/amp'; window.location.href = window.location.href + '/amp';
} }
}, 500); }, 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) { function matchDomain (domains) {