Add opt-in for setCookie (for specific sites)
This commit is contained in:
parent
f35ef11a82
commit
d9da63468b
@ -144,6 +144,7 @@ var blockedRegexes = {
|
||||
'americanbanker.com': /.+\.tinypass\.com\/.+/,
|
||||
'barrons.com': /cdn\.ampproject\.org\/v\d\/amp-access-.+\.js/,
|
||||
'belfasttelegraph.co.uk': /cdn\.flip-pay\.com\/clients\/inm\/flip-pay\.js/,
|
||||
'bizjournals.com': /(assets\.bizjournals\.com\/static\/js\/app\/cxense\.js|cdn\.cxense\.com)/,
|
||||
'bloomberg.com': /.+\.tinypass\.com\/.+/,
|
||||
'bostonglobe.com': /meter\.bostonglobe\.com\/js\/.+/,
|
||||
'businessinsider.com': /.+\.tinypass\.com\/.+/,
|
||||
@ -700,6 +701,26 @@ ext_api.webRequest.onCompleted.addListener(function (details) {
|
||||
urls: ["<all_urls>"]
|
||||
});
|
||||
|
||||
ext_api.runtime.onMessage.addListener(function (message, sender) {
|
||||
// check storage for opt in
|
||||
ext_api.storage.sync.get("optIn", function (result) {
|
||||
// send message back to content script with value of opt in
|
||||
ext_api.tabs.sendMessage(
|
||||
sender.tab.id, {
|
||||
"optIn": (true == result.optIn)
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// show the tab if we haven't registered the user reacting to the prompt.
|
||||
ext_api.storage.sync.get("optInShown", function (result) {
|
||||
if (!result.optInShown) {
|
||||
ext_api.tabs.create({
|
||||
url: "optin/opt-in.html"
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function isSiteEnabled(details) {
|
||||
var enabledSite = matchUrlDomain(enabledSites, details.url);
|
||||
if (enabledSite in restrictions) {
|
||||
|
@ -1,9 +1,38 @@
|
||||
"use strict";
|
||||
var ext_api = (typeof browser === 'object') ? browser : chrome;
|
||||
var domain;
|
||||
|
||||
// clean local storage of sites (with an exemption for hold-list)
|
||||
var arr_localstorage_hold = ['seekingalpha.com', 'sfchronicle.com'];
|
||||
if (!matchDomain(arr_localstorage_hold)){
|
||||
window.localStorage.clear();
|
||||
}
|
||||
|
||||
// listen to responses from background script
|
||||
ext_api.runtime.onMessage.addListener(function (message, sender) {
|
||||
// setCookie opt-in
|
||||
if (message.optIn) {
|
||||
// Australian Provincial Newspapers
|
||||
if (domain = matchDomain(['news-mail.com.au', 'frasercoastchronicle.com.au', 'gladstoneobserver.com.au', 'dailyexaminer.com.au', 'dailymercury.com.au', 'themorningbulletin.com.au', 'sunshinecoastdaily.com.au', 'gympietimes.com.au', 'northernstar.com.au', 'qt.com.au', 'thechronicle.com.au', 'warwickdailynews.com.au'])) {
|
||||
if (!cookieExists('subscribed')) {
|
||||
setCookie('subscribed', 'true', domain, '/', 14);
|
||||
}
|
||||
} else if (matchDomain('bostonglobe.com')) {
|
||||
if (!cookieExists('s_fid')) {
|
||||
let s_fid = genHexString(16) + '-' + genHexString(16);
|
||||
setCookie('s_fid', s_fid, 'bostonglobe.com', '/', 14);
|
||||
}
|
||||
} else if (domain = matchDomain(['independent.ie', 'belfasttelegraph.co.uk'])) {
|
||||
if (!cookieExists('subscriber')) {
|
||||
setCookie('subscriber', '{"subscriptionStatus": true}', domain, '/', 14);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// ask for opt-in confirmation
|
||||
ext_api.runtime.sendMessage({});
|
||||
|
||||
// Content workarounds/domain
|
||||
|
||||
if (matchDomain("thesaturdaypaper.com.au")) {
|
||||
@ -11,13 +40,6 @@ if (matchDomain("thesaturdaypaper.com.au")) {
|
||||
removeDOMElement(paywall);
|
||||
}
|
||||
|
||||
// Australian Provincial Newspapers
|
||||
else if (domain = matchDomain(['news-mail.com.au', 'frasercoastchronicle.com.au', 'gladstoneobserver.com.au', 'dailyexaminer.com.au', 'dailymercury.com.au', 'themorningbulletin.com.au', 'sunshinecoastdaily.com.au', 'gympietimes.com.au', 'northernstar.com.au', 'qt.com.au', 'thechronicle.com.au', 'warwickdailynews.com.au'])) {
|
||||
if (!cookieExists('subscribed')) {
|
||||
setCookie('subscribed', 'true', domain, '/', 14);
|
||||
}
|
||||
}
|
||||
|
||||
// Australian Community Media newspapers
|
||||
else if (window.location.hostname.endsWith(".com.au") || window.location.hostname.endsWith(".net.au")) {
|
||||
let au_sites = ['bendigoadvertiser.com.au', 'bordermail.com.au', 'canberratimes.com.au', 'centralwesterndaily.com.au', 'dailyadvertiser.com.au', 'dailyliberal.com.au', 'examiner.com.au', 'illawarramercury.com.au', 'newcastleherald.com.au', 'northerndailyleader.com.au', 'portnews.com.au', 'standard.net.au', 'theadvocate.com.au', 'thecourier.com.au', 'westernadvocate.com.au'];
|
||||
@ -277,18 +299,6 @@ else if (matchDomain("economist.com")) {
|
||||
});
|
||||
}
|
||||
|
||||
else if (matchDomain("bizjournals.com")) {
|
||||
const sheet_overlay = document.querySelector('.sheet-overlay');
|
||||
const chunk_paywall = document.querySelector('.chunk--paywall');
|
||||
removeDOMElement(sheet_overlay, chunk_paywall);
|
||||
const overlaids = document.querySelectorAll('.is-overlaid');
|
||||
for (let overlaid of overlaids) {
|
||||
overlaid.classList.remove('is-overlaid');
|
||||
}
|
||||
const body_hidden = document.querySelector('.js-pre-chunks__story-body');
|
||||
body_hidden.removeAttribute('style');
|
||||
}
|
||||
|
||||
else if (matchDomain("the-tls.co.uk")) {
|
||||
const paywall = document.querySelector('.tls-subscriptions-banner__closed-skin');
|
||||
removeDOMElement(paywall);
|
||||
@ -694,13 +704,6 @@ else if (matchDomain('spectator.co.uk')) {
|
||||
}, 500); // Delay (in milliseconds)
|
||||
}
|
||||
|
||||
else if (matchDomain('bostonglobe.com')) {
|
||||
if (!cookieExists('s_fid')) {
|
||||
let s_fid = genHexString(16) + '-' + genHexString(16);
|
||||
setCookie('s_fid', s_fid, 'bostonglobe.com', '/', 14);
|
||||
}
|
||||
}
|
||||
|
||||
else if (matchDomain('historyextra.com')) {
|
||||
let article_masked = document.querySelector('.template-article__masked');
|
||||
if (article_masked) {
|
||||
@ -712,12 +715,6 @@ else if (matchDomain('historyextra.com')) {
|
||||
removeDOMElement(ad_banner);
|
||||
}
|
||||
|
||||
else if (domain = matchDomain(['independent.ie', 'belfasttelegraph.co.uk'])) {
|
||||
if (!cookieExists('subscriber')) {
|
||||
setCookie('subscriber', '{"subscriptionStatus": true}', domain, '/', 14);
|
||||
}
|
||||
}
|
||||
|
||||
else if (matchDomain('republic.ru')) {
|
||||
let paywall = document.querySelector('.paywall-section');
|
||||
removeDOMElement(paywall);
|
||||
|
@ -292,5 +292,5 @@
|
||||
"webRequest",
|
||||
"webRequestBlocking"
|
||||
],
|
||||
"version": "1.8.4.0"
|
||||
"version": "1.8.4.2"
|
||||
}
|
||||
|
@ -21,5 +21,5 @@
|
||||
"page": "options.html"
|
||||
},
|
||||
"permissions": [ "cookies", "<all_urls>", "storage", "webRequest", "webRequestBlocking"],
|
||||
"version": "1.8.4.0"
|
||||
"version": "1.8.4.2"
|
||||
}
|
||||
|
9
optin/opt-in.css
Normal file
9
optin/opt-in.css
Normal file
@ -0,0 +1,9 @@
|
||||
html, body {
|
||||
width: 20em;
|
||||
padding-left: 0.5em;
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
|
||||
button {
|
||||
margin: 0.2em 0.2em 0.5em 0;
|
||||
}
|
30
optin/opt-in.html
Normal file
30
optin/opt-in.html
Normal file
@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Bypass Paywalls Clean (setCookie opt-in)</title>
|
||||
<link rel="stylesheet" href="opt-in.css"/>
|
||||
<script src="opt-in.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="opt-in-prompt">
|
||||
<p><strong>Bypass Paywalls Clean (setCookie opt-in)</strong></p>
|
||||
<p>For some sites (check list in options) a necessary cookie has to be set (this cookie doesn't contain any personal information about the user or device):</br></br>
|
||||
Australian Provincial Newspapers</br>
|
||||
Boston Globe</br>
|
||||
Irish Independent</br>
|
||||
The Belfast Telegraph</p>
|
||||
<p><span id="opt-in-enabled"></span></p>
|
||||
<div id="button-container">
|
||||
<button id="button-enable">Enable</button>
|
||||
<button id="button-cancel" autofocus="true">Disable</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="after-opt-in" hidden="true">
|
||||
<p>Do something else.</p>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
38
optin/opt-in.js
Normal file
38
optin/opt-in.js
Normal file
@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
var ext_api = chrome || browser;
|
||||
|
||||
window.addEventListener("load", function () {
|
||||
ext_api.storage.sync.get("optIn", function (result) {
|
||||
var opt_in_enabled = document.getElementById('opt-in-enabled');
|
||||
opt_in_enabled.appendChild(document.createTextNode('SetCookie opt-in enabled: ' + (result.optIn ? 'YES' : 'NO')));
|
||||
//console.log("Setting up UI. result.optIn:" + result.optIn);
|
||||
});
|
||||
|
||||
document.getElementById("button-enable").addEventListener(
|
||||
"click",
|
||||
function () {
|
||||
ext_api.storage.sync.set({
|
||||
"optIn": true,
|
||||
"optInShown": true
|
||||
});
|
||||
window.close();
|
||||
});
|
||||
|
||||
document.getElementById("button-cancel").addEventListener(
|
||||
"click",
|
||||
function () {
|
||||
ext_api.storage.sync.set({
|
||||
"optIn": false,
|
||||
"optInShown": true
|
||||
});
|
||||
window.close();
|
||||
});
|
||||
/**
|
||||
// set up the appearance of the popup depending on the outcome of the opt-in
|
||||
ext_api.storage.sync.get("optInShown", function (result) {
|
||||
console.log("Setting up UI. result.optInShown:" + result.optInShown);
|
||||
document.getElementById("opt-in-prompt").hidden = result.optInShown;
|
||||
document.getElementById("after-opt-in").hidden = !result.optInShown;
|
||||
});
|
||||
**/
|
||||
});
|
@ -17,11 +17,13 @@
|
||||
<h1>Options | <small><span id="version"></span><span id="version_new"></span></small></h1>
|
||||
<div style="width:90%;">
|
||||
Selected sites will have their cookies cleared and referer set to Google.
|
||||
You should uncheck sites you have an account with or else you will be logged out at every visit.
|
||||
You should uncheck sites you have an account with or else you will be logged out at every visit.</br>
|
||||
For some sites (check list) a necessary cookie has to be set; enable in opt-in.
|
||||
</div>
|
||||
<br/>
|
||||
<div style='float:left'>
|
||||
<small><button><a href="options_custom.html" style="text-decoration:none;color:inherit">Custom sites</a></button></small>
|
||||
<small><button><a href="optin/opt-in.html" style="text-decoration:none;color:inherit">Opt-in</a></button></small>
|
||||
<small><button><a href="options.html#save" style="text-decoration:none;color:inherit">Go to save</a></button></small>
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
|
8
sites.js
8
sites.js
@ -9,11 +9,11 @@ var defaultSites =
|
||||
"Atavist Magazine": "atavist.com",
|
||||
"Australia News Corp": "###_au_news_corp",
|
||||
"Australian Community Media (daily)": "###_au_comm_media",
|
||||
"Australian Provincial Newspapers (daily)": "###_au_prov_news",
|
||||
"Australian Provincial Newspapers (daily) (opt-in)": "###_au_prov_news",
|
||||
"Baltimore Sun": "baltimoresun.com",
|
||||
"Barron's": "barrons.com",
|
||||
"BBC History Extra": "historyextra.com",
|
||||
"Belfast Telegraph": "belfasttelegraph.co.uk",
|
||||
"Belfast Telegraph (opt-in)": "belfasttelegraph.co.uk",
|
||||
"Bloomberg": "bloomberg.com",
|
||||
"Bloomberg Quint (free articles only)": "bloombergquint.com",
|
||||
"Brisbane Times": "brisbanetimes.com.au",
|
||||
@ -73,7 +73,7 @@ var defaultSites =
|
||||
"Inc.com": "inc.com",
|
||||
"Inkl": "inkl.com",
|
||||
"Intelligent Investor": "intelligentinvestor.com.au",
|
||||
"Irish Independent": "independent.ie",
|
||||
"Irish Independent (opt-in)": "independent.ie",
|
||||
"Knack.be": "knack.be",
|
||||
"L'Écho": "lecho.be",
|
||||
"L'Opinion": "lopinion.fr",
|
||||
@ -149,7 +149,7 @@ var defaultSites =
|
||||
"The Athletic UK": "theathletic.co.uk",
|
||||
"The Atlantic": "theatlantic.com",
|
||||
"The Australian Financial Review": "afr.com",
|
||||
"The Boston Globe": "bostonglobe.com",
|
||||
"The Boston Globe (opt-in)": "bostonglobe.com",
|
||||
"The Business Journals": "bizjournals.com",
|
||||
"The Christian Science Monitor": "csmonitor.com",
|
||||
"The Daily Beast (free articles only)": "thedailybeast.com",
|
||||
|
Loading…
x
Reference in New Issue
Block a user