Add sites on Medium platform (remove cookies)

Works for all sites with a Medium subscription-login, but which are not on Medium (sub)domain.
Uses Medium-option to dis/enable.
mainfest.json needs in permissions: <all_urls>
This commit is contained in:
magnolia1234 2020-01-13 19:15:37 +01:00 committed by GitHub
parent 7761b05697
commit 99e866674b
3 changed files with 16 additions and 147 deletions

View File

@ -41,7 +41,7 @@ var defaultSites = {
'Les Echos': 'lesechos.fr',
'London Review of Books': 'lrb.co.uk',
'Los Angeles Times': 'latimes.com',
'Medium': 'medium.com',
'Medium (all sites)': 'medium.com',
'Medscape': 'medscape.com',
'MIT Technology Review': 'technologyreview.com',
'Mountain View Voice': 'mv-voice.com',
@ -333,6 +333,16 @@ browser.webRequest.onBeforeSendHeaders.addListener(function(details) {
continue;
}
}
// remove cookies for sites medium platform (mainfest.json needs in permissions: <all_urls>)
if (isSiteEnabled({url: '.medium.com'}) && details.url.indexOf('cdn-client.medium.com') !== -1 && header_referer.indexOf('.medium.com') === -1) {
var domainVar = new URL(header_referer).hostname;
browser.cookies.getAll({domain: domainVar}, function(cookies) {
for (var i=0; i<cookies.length; i++) {
browser.cookies.remove({url: (cookies[i].secure ? "https://" : "http://") + cookies[i].domain + cookies[i].path, name: cookies[i].name});
}
});
}
// check for blocked regular expression: domain enabled, match regex, block on an internal or external regex
for (var domain in blockedRegexes) {
@ -367,7 +377,7 @@ browser.webRequest.onBeforeSendHeaders.addListener(function(details) {
// this fixes images not being loaded on cooking.nytimes.com main page
// referrer has to be *nytimes.com otherwise returns 403
requestHeader.value = 'https://cooking.nytimes.com';
} else if (details.url.indexOf("wsj.com") !== -1 || details.url.indexOf("ft.com") !== -1) {
} else if (details.url.indexOf("ft.com") !== -1) {
requestHeader.value = 'https://www.facebook.com/';
} else {
requestHeader.value = 'https://www.google.com/';
@ -383,7 +393,7 @@ browser.webRequest.onBeforeSendHeaders.addListener(function(details) {
// otherwise add it
if (!setReferer) {
if (details.url.indexOf("wsj.com") !== -1) {
if (details.url.indexOf("ft.com") !== -1) {
requestHeaders.push({
name: 'Referer',
value: 'https://www.facebook.com/'

View File

@ -2,46 +2,6 @@
"background": {
"scripts": ["background.js"]
},
"content_scripts": [
{
"matches": [
"*://*.bizjournals.com/*",
"*://*.bloomberg.com/*",
"*://*.businessinsider.com/*",
"*://*.caixinglobal.com/*",
"*://*.ad.nl/*",
"*://*.ed.nl/*",
"*://*.haaretz.co.il/*",
"*://*.lemonde.fr/*",
"*://*.nytimes.com/*",
"*://*.nzherald.co.nz/*",
"*://*.parool.nl/*",
"*://*.repubblica.it/*",
"*://*.telegraaf.nl/*",
"*://*.trouw.nl/*",
"*://*.volkskrant.nl/*",
"*://*.washingtonpost.com/*",
"*://*.economist.com/*",
"*://*.the-tls.co.uk/*",
"*://*.leparisien.fr/*",
"*://*.nrc.nl/*",
"*://*.theathletic.com/*",
"*://*.techinasia.com/*",
"*://*.newcastleherald.com.au/*",
"*://*.thestar.com/*",
"*://*.afr.com/*",
"*://*.theglobeandmail.com/*",
"*://*.scribd.com/*",
"*://*.technologyreview.com/*",
"*://*.thetimes.co.uk/*",
"*://*.haaretz.com/*",
"*://*.asia.nikkei.com/*",
"*://*.hbr.org/*",
"*://*.bloombergquint.com/*"
],
"js": ["contentScript.js"]
}
],
"applications": {
"gecko": {
"id": "magnolia@12.34",
@ -73,111 +33,10 @@
},
"permissions": [
"cookies",
"<all_urls>",
"storage",
"webRequest",
"webRequestBlocking",
"*://*.baltimoresun.com/*",
"*://*.barrons.com/*",
"*://*.bloomberg.com/*",
"*://*.businessinsider.com/*",
"*://*.caixinglobal.com/*",
"*://*.cen.acs.org/*",
"*://*.chicagotribune.com/*",
"*://*.centralwesterndaily.com.au/*",
"*://*.chicagobusiness.com/*",
"*://*.corriere.it/*",
"*://*.dailypress.com/*",
"*://*.denverpost.com/*",
"*://*.tijd.be/*",
"*://*.volkskrant.nl/*",
"*://*.economist.com/*",
"*://*.examiner.com.au/*",
"*://*.ft.com/*",
"*://*.foreignpolicy.com/*",
"*://*.glassdoor.com/*",
"*://*.haaretz.co.il/*",
"*://*.haaretz.com/*",
"*://*.handelsblatt.com/*",
"*://*.courant.com/*",
"*://*.hbr.org/*",
"*://*.inc.com/*",
"*://*.investorschronicle.co.uk/*",
"*://*.repubblica.it/*",
"*://*.letemps.ch/*",
"*://*.latimes.com/*",
"*://*.medium.com/*",
"*://*.medscape.com/*",
"*://*.technologyreview.com/*",
"*://*.mv-voice.com/*",
"*://*.nationalpost.com/*",
"*://*.newstatesman.com/*",
"*://*.nymag.com/*",
"*://*.nzherald.co.nz/*",
"*://*.asia.nikkei.com/*",
"*://*.nrc.nl/*",
"*://*.ocregister.com/*",
"*://*.orlandosentinel.com/*",
"*://*.paloaltoonline.com/*",
"*://*.quora.com/*",
"*://*.sun-sentinel.com/*",
"*://*.theadvocate.com.au/*",
"*://*.theage.com.au/*",
"*://*.theaustralian.com.au/*",
"*://*.themercury.com.au/*",
"*://*.afr.com/*",
"*://*.bostonglobe.com/*",
"*://*.bizjournals.com/*",
"*://*.theglobeandmail.com/*",
"*://*.newcastleherald.com.au/*",
"*://*.japantimes.co.jp/*",
"*://*.themarker.com/*",
"*://*.mercurynews.com/*",
"*://*.mcall.com/*",
"*://*.thenation.com/*",
"*://*.nytimes.com/*",
"*://*.newyorker.com/*",
"*://*.news-gazette.com/*",
"*://*.thesaturdaypaper.com.au/*",
"*://*.spectator.co.uk/*",
"*://*.seattletimes.com/*",
"*://*.smh.com.au/*",
"*://*.telegraph.co.uk/*",
"*://*.thetimes.co.uk/*",
"*://*.thestar.com/*",
"*://*.washingtonpost.com/*",
"*://*.wsj.com/*",
"*://*.towardsdatascience.com/*",
"*://*.vanityfair.com/*",
"*://*.wired.com/*",
"*://*.thediplomat.com/*",
"*://*.theatlantic.com/*",
"*://*.qz.com/*",
"*://*.ad.nl/*",
"*://*.ed.nl/*",
"*://*.groene.nl/*",
"*://*.parool.nl/*",
"*://*.telegraaf.nl/*",
"*://*.trouw.nl/*",
"*://*.vn.nl/*",
"*://*.lemonde.fr/*",
"*://*.scientificamerican.com/*",
"*://*.thehindu.com/*",
"*://*.demorgen.be/*",
"*://*.tinypass.com/*",
"*://*.lrb.co.uk/*",
"*://*.the-tls.co.uk/*",
"*://*.harpers.org/*",
"*://*.nknews.org/*",
"*://*.inquirer.com/*",
"*://*.indiatimes.com/*",
"*://*.leparisien.fr/*",
"*://*.lesechos.fr/*",
"*://*.theathletic.com/*",
"*://*.techinasia.com/*",
"*://*.scribd.com/*",
"*://*.lecho.be/*",
"*://*.bloombergquint.com/*",
"*://*.statista.com/*"
"webRequestBlocking"
],
"version": "1.6.3.3"
}

View File

@ -39,7 +39,7 @@ var defaultSites = {
'Les Echos (free articles only)': 'lesechos.fr',
'London Review of Books': 'lrb.co.uk',
'Los Angeles Times': 'latimes.com',
'Medium': 'medium.com',
'Medium (all sites)': 'medium.com',
'Medscape': 'medscape.com',
'MIT Technology Review': 'technologyreview.com',
'Mountain View Voice': 'mv-voice.com',