From 4d04b3f1fcacf7af53a30edb3732fb6090649f41 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Mon, 8 Jun 2020 16:44:46 +0200 Subject: [PATCH] Add Irish Independent --- README.md | 1 + background.js | 2 ++ contentScript.js | 24 +++++++++++++++++++----- lp/manifest.json | 15 +++------------ sites.js | 1 + 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 4fea798..d1da136 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,7 @@ Install add-on by downloading xpi-file. ##### United Kingdom/Ireland [Financial News](https://www.fnlondon.com) - [Financial Times](https://www.ft.com) - +[Irish Independent](https://www.independent.ie) - [London Review of Books](https://www.lrb.co.uk) - [The Athletic UK](https://theathletic.com) - [The Economist](https://www.economist.com) - diff --git a/background.js b/background.js index 71d7391..3dea683 100644 --- a/background.js +++ b/background.js @@ -41,6 +41,7 @@ var allow_cookies = [ 'handelsblatt.com', 'heraldsun.com.au', 'humo.be', +'independent.ie', 'intelligentinvestor.com.au', 'kleinezeitung.at', 'lc.nl', @@ -170,6 +171,7 @@ var blockedRegexes = { 'haaretz.com': /haaretz\.com\/hdc\/web\/js\/minified\/header-scripts-int.js.+/, 'historyextra.com': /.+\.evolok\.net\/.+\/authorize\/.+/, 'ilmessaggero.it': /(utils\.cedsdigital\.it\/js\/PaywallMeter\.js|static\.viralize\.tv\/viralize_player)/, +'independent.ie': /cdn\.flip-pay\.com\/clients\/inm\/flip-pay\.js/, 'inquirer.com': /.+\.tinypass\.com\/.+/, 'ladepeche.fr': /.+\.poool\.fr\/.+/, 'lastampa.it': /.+\.repstatic\.it\/minify\/sites\/lastampa\/.+\/config\.cache\.php\?name=social_js/, diff --git a/contentScript.js b/contentScript.js index 025077b..5d46862 100644 --- a/contentScript.js +++ b/contentScript.js @@ -71,7 +71,7 @@ else if (matchDomain('telegraaf.nl')) { removeDOMElement(article_body_old); let json = document.querySelector('script[type="application/ld+json"][data-react-helmet="true"]'); if (json) { - json_text = JSON.parse(json.text).articleBody; + var json_text = JSON.parse(json.text).articleBody; let article_body = document.querySelector('section.TextArticlePage__bodyText'); if (article_body) { let div_main = document.createElement("div"); @@ -540,8 +540,7 @@ else if (matchDomain('barrons.com')) { href = signin_links[i].href; if (href.includes('target=')) { href = href.split('target')[1].split('%3F')[0]; - href = href.replace('=', '').replace('%3A', ':'); - href = href.replace('%2F', '/').replace('%2F', '/').replace('%2F', '/').replace('%2F', '/'); + href = href.replace('=', '').replace('%3A', ':').replace(/%2F/g, '/'); signin_links[i].href = href; signin_links[i].text = 'Click'; } @@ -675,9 +674,9 @@ else if (matchDomain('spectator.co.uk')) { } else if (matchDomain('bostonglobe.com')) { - if (!document.cookie.split(';').some(function(item) { return item.trim().indexOf('s_fid=') === 0 })) { + if (!cookieExists('s_fid')) { let s_fid = genHexString(16) + '-' + genHexString(16); - document.cookie = "s_fid=" + s_fid + "; domain=bostonglobe.com; path=/; max-age=1209600"; + setCookie('s_fid', s_fid, 'bostonglobe.com', '/', 14); } } @@ -694,6 +693,12 @@ else if (matchDomain('historyextra.com')) { removeDOMElement(ad_banner); } +else if (matchDomain('independent.ie')) { + if (!cookieExists('subscriber')) { + setCookie('subscriber', '{"subscriptionStatus": true}', 'www.independent.ie', '/', 14); + } +} + // General Functions function removeDOMElement(...elements) { for (let element of elements) { @@ -720,6 +725,15 @@ function removeClassesByPrefix(el, prefix) { } } +function cookieExists(name) { + return document.cookie.split(';').some(function(item) { return item.trim().indexOf(name + '=') === 0 }) +} + +function setCookie(name, value, domain, path, days) { + var max_age = days * 24 * 60 * 60; + document.cookie = name + "=" + (value || "") + "; domain=" + domain + "; path=" + path + "; max-age=" + max_age; +} + function genHexString(len) { let output = ''; for (let i = 0; i < len; i++) { diff --git a/lp/manifest.json b/lp/manifest.json index 9d1b159..d1a93e3 100644 --- a/lp/manifest.json +++ b/lp/manifest.json @@ -3,17 +3,6 @@ "scripts": ["sites.js", "background.js"] }, "content_security_policy": "script-src 'self'; object-src 'self'", - "content_scripts": [{ - "matches": [ - "*://*.bloomberg.com/*", - "*://*.economist.com/*", - "*://*.nytimes.com/*", - "*://*.theathletic.com/*", - "*://*.washingtonpost.com/*" - ], - "js": ["contentScript.js"] - } - ], "applications": { "gecko": { "id": "magnolia_limited_permissions@12.34", @@ -123,6 +112,7 @@ "*://*.ilmanifesto.it/*", "*://*.ilmessaggero.it/*", "*://*.inc.com/*", + "*://*.independent.ie/*", "*://*.inquirer.com/*", "*://*.intelligentinvestor.com.au/*", "*://*.irishtimes.com/*", @@ -244,7 +234,9 @@ "*://*.ampproject.org/*", "*://*.cedsdigital.it/*", "*://*.corriereobjects.it/*", + "*://*.emol.cl/*", "*://*.epimg.net/*", + "*://*.flip-pay.com/*", "*://*.htmedia.in/*", "*://*.lightboxcdn.com/*", "*://*.lp4.io/*", @@ -254,7 +246,6 @@ "*://*.repstatic.it/*", "*://*.userzoom.com/*", "*://*.viralize.tv/*", - "*://merreader.emol.cl/*", "*://*.bndestem.nl/*", "*://*.bd.nl/*", "*://*.ed.nl/*", diff --git a/sites.js b/sites.js index aeac252..e69787d 100644 --- a/sites.js +++ b/sites.js @@ -64,6 +64,7 @@ var defaultSites = "Il Messaggero": "ilmessaggero.it", "Illawarra Mercury": "illawarramercury.com.au", "Intelligent Investor": "intelligentinvestor.com.au", + "Irish Independent": "independent.ie", "Kleine Zeitung": "kleinezeitung.at", "L'Écho": "lecho.be", "L'Opinion": "lopinion.fr",