Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
Make extension remove ads from the page
Browse files Browse the repository at this point in the history
  • Loading branch information
krisztianb committed Sep 15, 2024
1 parent b73d7e3 commit 1ce0785
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ The extension only operates on pages similar to the following:
### Installation

Currently only available for Firefox: https://addons.mozilla.org/en-US/firefox/addon/seeking-alpha-paywall-remover/

### Troubleshooting

If the extension doesn't seem to work for you please try the following before opening an [issue ticket](https://github.com/krisztianb/seekingalpha-paywall-remover/issues):

* Make sure you have the latest version of the extension installed (you can use the URL `about:addons` in Firefox)
* Delete all seekingalpha.com cookies in your browser (key combination Ctrl + Alt + Del)
* Reload the page while holding down the SHIFT button (= reload ignoring cached content)
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Seeking Alpha Paywall Remover",
"version": "1.5",
"version": "1.6",
"description": "Removes the paywall from news and article pages on the seekingalpha.com website",
"icons": {
"48": "icons/48x48.png",
Expand Down
10 changes: 10 additions & 0 deletions paywall-remover.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ const payWallSelectors = [
const overlaySelector = "div.bg-black\\/30"; // this is the element creating the gray semi-transparent overlay effect
const contentWrapperSelector = ".contents";
const articleSelector = "main article section";
const adSelector = "main + div"; // might contain "special offer" ads

// Store the original non-pay-walled content
const content = document.querySelector(articleSelector).innerHTML;

removeAds();

// Code executed once the paywall is shown
new window.MutationObserver(function (mutations) {
for (const mutation of mutations) {
Expand Down Expand Up @@ -73,3 +76,10 @@ function removeInteractivityLock() {
function restoreContent() {
document.querySelector(articleSelector).innerHTML = content;
}

function removeAds() {
const ad = document.querySelector(adSelector);
if (ad) {
ad.remove();
}
}

0 comments on commit 1ce0785

Please sign in to comment.