Fix-update Barron's (amp for snippet)

This commit is contained in:
magnolia1234 2020-06-15 22:21:42 +02:00
parent 710ac16453
commit 8b11df84be
2 changed files with 20 additions and 10 deletions

View file

@ -8,7 +8,7 @@ var ext_api = (typeof browser === 'object') ? browser : chrome;
// var defaultSites = {};
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}\/.+/,
'elcomercio.pe': /.+\/elcomercio.pe\/.+((\w)+(\-)+){3,}.+/,
'gestion.pe': /.+\/gestion.pe\/.+((\w)+(\-)+){3,}.+/,
@ -145,6 +145,7 @@ var blockedRegexes = {
'adweek.com': /.+\.lightboxcdn\.com\/.+/,
'afr.com': /afr\.com\/assets\/vendorsReactRedux_client.+\.js/,
'americanbanker.com': /.+\.tinypass\.com\/.+/,
'barrons.com': /cdn\.ampproject\.org\/v\d\/amp-access-.+\.js/,
'bloomberg.com': /.+\.tinypass\.com\/.+/,
'bostonglobe.com': /meter\.bostonglobe\.com\/js\/.+/,
'businessinsider.com': /(.+\.tinypass\.com\/.+|cdn\.onesignal\.com\/sdks\/.+\.js)/,

View file

@ -509,15 +509,24 @@ else if (matchDomain('challenges.fr')) {
}
else if (matchDomain('barrons.com')) {
var href = '';
const signin_links = document.querySelectorAll('a.primary-button--link');
for (let i = 0; i < signin_links.length; i++) {
href = signin_links[i].href;
if (href.includes('target=')) {
href = href.split('target')[1].split('%3F')[0];
href = href.replace('=', '').replace('%3A', ':').replace(/%2F/g, '/');
signin_links[i].href = href;
signin_links[i].text = 'Click';
document.addEventListener('DOMContentLoaded', () => {
let body_continuous = document.querySelector('body.is-continuous');
let snippet = document.querySelector('meta[content="snippet"]');
if (body_continuous && snippet) {
window.location.href = window.location.href.replace('barrons.com', 'barrons.com/amp');
}
});
if (!window.location.href.includes('barrons.com/amp/')) {
var href = '';
let signin_links = document.querySelectorAll('a.primary-button--link');
for (let signin_link of signin_links) {
href = signin_link.href;
if (href.includes('target=')) {
href = href.split('target')[1].split('%3F')[0];
href = href.replace('=', '').replace('%3A', ':').replace(/%2F/g, '/');
signin_link.href = href;
signin_link.text = 'Click';
}
}
}
}