From 7e6bb84c05e1b7a80e8a0e092b41fccb0be28775 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Thu, 2 Jul 2020 12:43:12 +0200 Subject: [PATCH] Add Atavist Magazine & Nautilus --- README.md | 2 ++ contentScript.js | 9 +++++++++ lp/manifest.json | 2 ++ options.js | 19 +++++++++++-------- sites.js | 2 ++ 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ad4048e..149f1b6 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ Install add-on by downloading xpi-file. [Discover Magazine](https://www.discovermagazine.com) - [MIT Technology Review](https://www.technologyreview.com) - [National Geographic USA](https://www.nationalgeographic.com) - +[Nautilus](https://nautil.us) - [Towards Data Science](https://www.towardsdatascience.com) - [Wired](https://www.wired.com) - [Scientific American](https://www.scientificamerican.com)* @@ -71,6 +72,7 @@ Install add-on by downloading xpi-file. [Slader](https://www.slader.com) - [Statista](https://www.statista.com) ##### Blogs +[Atavist Magazine](https://magazine.atavist.com) - [Medium](https://www.medium.com) (all sites) - [SofRep](https://sofrep.com) - [The Daily Beast](https://www.thedailybeast.com)* diff --git a/contentScript.js b/contentScript.js index d8cd085..387391e 100644 --- a/contentScript.js +++ b/contentScript.js @@ -779,6 +779,15 @@ else if (matchDomain('qz.com')) { }, 500); // Delay (in milliseconds) } +else if (matchDomain("magazine.atavist.com")) { + let bottom_notification = document.querySelector('div.bottom-notification'); + let overlay = document.querySelector('div.notification-overlay'); + removeDOMElement(bottom_notification, overlay); + let paywall = document.querySelector('body.paywall-notification-visible'); + if (paywall) + paywall.classList.remove('paywall-notification-visible'); +} + // General Functions function removeDOMElement(...elements) { for (let element of elements) { diff --git a/lp/manifest.json b/lp/manifest.json index 2914718..b73803f 100644 --- a/lp/manifest.json +++ b/lp/manifest.json @@ -43,6 +43,7 @@ "*://*.americanaffairsjournal.org/*", "*://*.americanbanker.com/*", "*://*.asia.nikkei.com/*", + "*://*.atavist.com/*", "*://*.baltimoresun.com/*", "*://*.barrons.com/*", "*://*.bendigoadvertiser.com.au/*", @@ -152,6 +153,7 @@ "*://*.nationalgeographic.com/*", "*://*.nationalpost.com/*", "*://*.nationalreview.com/*", + "*://*.nautil.us/*", "*://*.newcastleherald.com.au/*", "*://*.newrepublic.com/*", "*://*.news-gazette.com/*", diff --git a/options.js b/options.js index 11e620e..ae2db60 100644 --- a/options.js +++ b/options.js @@ -46,6 +46,7 @@ function renderOptions() { }, function(items) { var sites = items.sites; var sitesEl = document.getElementById('bypass_sites'); + var clean_key; for (var key in defaultSites) { if (!defaultSites.hasOwnProperty(key)) { continue; @@ -57,19 +58,20 @@ function renderOptions() { inputEl.type = 'checkbox'; inputEl.dataset.key = key; inputEl.dataset.value = value; - inputEl.checked = (key in sites) || (key.replace(/\s\(.*\)/, '') in sites); + clean_key = key.replace(/\s\(.*\)/, ''); + inputEl.checked = Object.keys(sites).some(title => (title.replace(/\s\(.*\)/, '') === clean_key)); if (value !== '###') { - labelEl.appendChild(inputEl); + labelEl.appendChild(inputEl); } - labelEl.appendChild(document.createTextNode(' '+key)); + labelEl.appendChild(document.createTextNode(' ' + key)); sitesEl.appendChild(labelEl); } - // custom + // custom var labelEl = document.createElement('label'); labelEl.appendChild(document.createTextNode(' ——— Custom Sites ———')); sitesEl.appendChild(labelEl); var sites_custom = items.sites_custom; - for (var key in sites_custom) { + for (var key in sites_custom) { if (defaultSites.hasOwnProperty(key)) { continue; } @@ -80,13 +82,14 @@ function renderOptions() { inputEl.type = 'checkbox'; inputEl.dataset.key = key; inputEl.dataset.value = value; - inputEl.checked = (key in sites) || (key.replace(/\s\(.*\)/, '') in sites); - if (value !== '' && value !== '###') { + clean_key = key.replace(/\s\(.*\)/, ''); + inputEl.checked = Object.keys(sites).some(title => (title.replace(/\s\(.*\)/, '') === clean_key)); + if (value !== '' && value !== '###') { labelEl.appendChild(inputEl); } labelEl.appendChild(document.createTextNode(' '+key)); sitesEl.appendChild(labelEl); - } + } }); } diff --git a/sites.js b/sites.js index b1c53d7..c95ce58 100644 --- a/sites.js +++ b/sites.js @@ -6,6 +6,7 @@ var defaultSites = "Algemeen Dagblad": "ad.nl", "American Affairs": "americanaffairsjournal.org", "American Banker": "americanbanker.com", + "Atavist Magazine": "atavist.com", "Baltimore Sun": "baltimoresun.com", "Barron's": "barrons.com", "BBC History Extra": "historyextra.com", @@ -101,6 +102,7 @@ var defaultSites = "Mountain View Voice": "mv-voice.com", "National Post": "nationalpost.com", "National Review": "nationalreview.com", + "Nautilus": "nautil.us", "Neue Zürcher Zeitung": "nzz.ch", "New York Magazine": "nymag.com", "New Zealand Herald": "nzherald.co.nz",