diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e69de29
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..17141a1
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2019 Kalpaj Agrawalla
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..8edb911
--- /dev/null
+++ b/README.md
@@ -0,0 +1,21 @@
+
+
+ :cookie: CookieJar
+
+
+
+A browser extension that removes article-limit restriction from Medium, Technologyreview, NYTimes, and Washingtonpost, thus allowing the reader, with access to view unlimited premium and non-premium articles.
+
+## Procedure to use this browser extension (unpacked)
+
+Clone this repository / Download and unzip
+
+### Load the extension in Chrome / Opera
+1. Open Chrome / Opera browser and navigate to `chrome://extensions`
+2. On the top-right of this page, enable `Developer Mode` and then click on `Load unpacked extension`
+3. When prompted to choose a folder/file, navigate to the cloned/downloaded folder and choose `cookie-jar`
+4. Enable the extension now.
+5. Go ahead and start reading articles now!
+
+
+**Note:** For this extension to work on Medium, please sign-out of Medium first.
\ No newline at end of file
diff --git a/manifest.json b/manifest.json
new file mode 100644
index 0000000..600ddce
--- /dev/null
+++ b/manifest.json
@@ -0,0 +1,45 @@
+{
+ "manifest_version": 2,
+ "name": "CookieJar",
+ "version": "2.3.0",
+ "author": "Kalpaj Agrawalla",
+ "description": "Provides access to view unlimited premium and non-premium articles.",
+ "icons": {
+ "16": "src/icons/16.png",
+ "32": "src/icons/32.png",
+ "48": "src/icons/48.png",
+ "128": "src/icons/128.png"
+ },
+ "browser_action": {
+ "default_title": "CookieJar",
+ "default_icon": "src/icons/default.png"
+ },
+ "background": {
+ "scripts": [
+ "src/scripts/background.js"
+ ],
+ "persistent": true
+ },
+ "content_scripts": [{
+ "run_at": "document_start",
+ "all_frames": false,
+ "matches": [
+ ""
+ ],
+ "js": [
+ "src/scripts/content.js"
+ ]
+ }],
+ "minimum_chrome_version": "70",
+ "permissions": [
+ "",
+ "tabs",
+ "storage",
+ "cookies",
+ "contextMenus",
+ "contentSettings",
+ "browsingData",
+ "webRequest",
+ "webRequestBlocking"
+ ]
+}
\ No newline at end of file
diff --git a/src/icons/128.png b/src/icons/128.png
new file mode 100644
index 0000000..12f8c6c
Binary files /dev/null and b/src/icons/128.png differ
diff --git a/src/icons/16.png b/src/icons/16.png
new file mode 100644
index 0000000..f66f8ea
Binary files /dev/null and b/src/icons/16.png differ
diff --git a/src/icons/32.png b/src/icons/32.png
new file mode 100644
index 0000000..4669382
Binary files /dev/null and b/src/icons/32.png differ
diff --git a/src/icons/48.png b/src/icons/48.png
new file mode 100644
index 0000000..1ce3fa5
Binary files /dev/null and b/src/icons/48.png differ
diff --git a/src/icons/default.png b/src/icons/default.png
new file mode 100644
index 0000000..afef690
Binary files /dev/null and b/src/icons/default.png differ
diff --git a/src/scripts/background.js b/src/scripts/background.js
new file mode 100644
index 0000000..bd0013a
--- /dev/null
+++ b/src/scripts/background.js
@@ -0,0 +1,103 @@
+var urlPatterns = [
+ "*://*.technologyreview.com/*",
+ "*://*.nytimes.com/*",
+ "*://*.washingtonpost.com/*",
+ "*://*.medium.com/*",
+];
+
+var urlPatternsNames = [
+ "technologyreview",
+ "nytimes",
+ "washingtonpost",
+ "medium"
+];
+
+function removeAllCookies(currTabDomain) {
+
+ if (!chrome.cookies) {
+ chrome.cookies = chrome.experimental.cookies;
+ }
+
+ var removeCookie = function(cookie) {
+ var url = "http" + (cookie.secure ? "s" : "") + "://" + cookie.domain + cookie.path;
+ chrome.cookies.remove({
+ url,
+ "name": cookie.name
+ });
+ };
+
+ chrome.cookies.getAll({
+ domain: currTabDomain
+ }, function(allCookies) {
+ var count = allCookies.length;
+ // console.log(count);
+ for (var i = 0; i < count; i++) {
+ // console.log(allCookies[i]);
+ removeCookie(allCookies[i]);
+ }
+ });
+}
+
+chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
+ if (msg.action.localeCompare("BlockCookies") === 0) {
+ var currTabURL = sender.url || "invalid";
+ var localurlPattern;
+
+ for (let i = 0; i < urlPatterns.length; i++) {
+ if (currTabURL.includes(urlPatternsNames[i])) {
+ localurlPattern = urlPatterns[i];
+ break;
+ }
+ }
+
+ var contentSettings = chrome.contentSettings;
+ contentSettings.cookies.clear({}, function() {
+ contentSettings.cookies.set({
+ "primaryPattern": localurlPattern || "http://www.example.com/*",
+ "setting": "block"
+ });
+ });
+ } else if (msg.action.localeCompare("ClearCookies") === 0) {
+ var currTabURL = sender.url || "invalid";
+ var localurlPattern;
+
+ for (let i = 0; i < urlPatternsNames.length; i++) {
+ if (currTabURL.includes(urlPatternsNames[i])) {
+ localurlPattern = urlPatternsNames[i];
+ break;
+ }
+ }
+ let currTabDomain = "." + localurlPattern + ".com";
+ removeAllCookies(currTabDomain);
+ // originName = "https://www." + localurlPattern + ".com"
+ // chrome.browsingData.remove({
+ // "origins": [originName]
+ // }, {
+ // "appcache": true,
+ // "cache": true,
+ // "cacheStorage": true,
+ // "cookies": true,
+ // "fileSystems": true,
+ // "indexedDB": true,
+ // "localStorage": true,
+ // "pluginData": true,
+ // "serviceWorkers": true,
+ // "webSQL": true
+ // }, function () {
+ // console.log("Cleared");
+ // });
+ }
+ return true;
+});
+
+chrome.webRequest.onBeforeRequest.addListener(
+ function() {
+ return {
+ cancel: true
+ };
+ }, {
+ urls: ["*://meter-svc.nytimes.com/*"],
+ // types: ["script"]
+ },
+ ["blocking"]
+);
\ No newline at end of file
diff --git a/src/scripts/content.js b/src/scripts/content.js
new file mode 100644
index 0000000..03228e3
--- /dev/null
+++ b/src/scripts/content.js
@@ -0,0 +1,67 @@
+var windowURL = window.location.href;
+
+function sendMessagetoBackground(message) {
+ chrome.runtime.sendMessage({
+ action: message
+ }, function() {});
+}
+
+function compareStr(newUrl) {
+ return windowURL.includes(newUrl);
+}
+
+if (compareStr("medium")) {
+ sendMessagetoBackground("BlockCookies");
+ window.onload = function() {
+ sendMessagetoBackground("ClearCookies");
+
+ var removeElement = document.getElementById("lo-meter-banner-background-color");
+ if (removeElement) {
+ removeElement.remove();
+ }
+ };
+} else if (compareStr("technologyreview")) {
+ sendMessagetoBackground("ClearCookies");
+ window.onload = function() {
+ sendMessagetoBackground("ClearCookies");
+ localStorage.clear();
+ sessionStorage.clear();
+
+ // Remove meter
+ let removeElement = document.getElementsByClassName(document.querySelector('[class$="meter"]').className);
+ if (removeElement[0]) {
+ removeElement[0].remove();
+ }
+
+ // Remove top banner
+ removeElement = document.getElementsByClassName("optanon-alert-box-wrapper hide-accept-button ");
+ if (removeElement[0]) {
+ removeElement[0].remove();
+ }
+ };
+} else if (compareStr("nytimes")) {
+ sendMessagetoBackground("ClearCookies");
+ window.onload = function() {
+ sendMessagetoBackground("ClearCookies");
+
+ let paymentGate1 = document.getElementsByClassName("css-1oqptyt");
+ let paymentGate2 = document.getElementsByClassName("css-c9itql-BestInShowHeadline e1jfbhl4");
+ let paymentGate3 = document.getElementsByClassName("css-v0hq7s");
+
+ if (paymentGate1.length > 0 || paymentGate2.length > 0 || paymentGate3.length > 0) {
+ window.location.reload(true);
+ }
+ };
+} else if (compareStr("washingtonpost")) {
+ sendMessagetoBackground("ClearCookies");
+ window.onload = function() {
+ sendMessagetoBackground("ClearCookies");
+ localStorage.clear();
+ sessionStorage.clear();
+
+ let removeElement = document.getElementById("i_userMessages");
+ if (removeElement) {
+ removeElement.remove();
+ }
+ };
+}
\ No newline at end of file