-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore]: performed squash on prev 44 commits.
This squash was performed to clean up cluttered commits and commit messages. All the open issues and PR's pre-squash, are fixed in this commit. As a result to squash, previous releases from github are deleted. This commit contains the code for v2.3.0 The readme section provides all functionalities, this extension provides. Finally, all issues will be tracked from the github issue webpage. -kalpaj agrawalla
- Loading branch information
0 parents
commit 84936e5
Showing
11 changed files
with
257 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div align="center"> | ||
<h1> | ||
:cookie: CookieJar | ||
</h1> | ||
</div> | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": [ | ||
"<all_urls>" | ||
], | ||
"js": [ | ||
"src/scripts/content.js" | ||
] | ||
}], | ||
"minimum_chrome_version": "70", | ||
"permissions": [ | ||
"<all_urls>", | ||
"tabs", | ||
"storage", | ||
"cookies", | ||
"contextMenus", | ||
"contentSettings", | ||
"browsingData", | ||
"webRequest", | ||
"webRequestBlocking" | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
}; | ||
} |