Giter VIP home page Giter VIP logo

demodal's Introduction

Demodal

Demodal is a browser extension that automatically removes content blocking modals including paywalls, discount offers, promts to sign up or enter your email address and more.

Modal dialogues such as paywalls, discount offers, cookie prompts and GDPR banners are user-hostile interfaces that demand your attention and interrupt your browsing experience. Demodal puts you back in control, letting you focus on the content.

Installation

Google Chrome

https://chrome.google.com/webstore/detail/demodal/fjhbdkfknppikobblnjibmkmogjeffcf

Install locally:

  • Clone this repository
  • Run ./run manifest v3 or copy manifest-v3.json to manifest.json
  • Go to about:extensions
  • Enable 'Developer mode'
  • Click 'Load unpacked'
  • Select the project folder

Mozilla Firefox

https://addons.mozilla.org/firefox/addon/demodal

Install locally:

  • Clone this repository
  • Run ./run manifest v2 or copy manifest-v2.json to manifest.json
  • Go go about:debugging#/runtime/this-firefox
  • Click 'Load Temporary Add-on'
  • Select manifest.json

Contributing

This extension is in early development. You can help by reporting websites with modals that didn't get blocked, or by creating your own definitions and sharing them with us and the community. The aim is to build up a comprehensive set of rules over time to block modals anywhere.

Demodal is not an ad-blocker. Only create definitions for UI elements that intefere with reading of content.

When submitting a pull request, please include a screenshot of the element that's being blocked and a link to a website to test.

Every definition should clearly match one modal type (e.g. consent request or paywall). Don't create overly broad definitions (e.g. div.modal) that could block legimitate modals.

Specification

Modal types

Type Description
consent Cookie and GDPR notices.
donate Prompts to make a donation.
email Prompts to enter your email address.
message General messages and notifications.
offer Promotions and discounts.
paywall Prompts to sign up for a paid subscription.
signup Prompts to create an account.

Definitions

Definitions are located in /definitions, file-separated by modal type. Definitions are grouped by URL pattern.

{
  "<glob> [ <glob> ... ]": { // URL pattern
    // Definition
    "if <function> [ <function> ... ]": { // Condition
      "<selector>": "<function> [ <argument> ... ]" // Action
    },
    // Definition (shorthand, no condition)
    "<selector>": "<function> [ <argument> ... ]" // Action
  }
}

Examples

{
  "*.example.com *.example.org": {
    "if $(.modal)": {
      ".modal": "remove" // Remove element if present
    },
    ".modal": "addClass hide" // Remove element (shorthand)
    "if defined(ModalDialog)": {
      "ModalDialog.close": "call" // Call function if defined
    },
    "if defined(ModalDialog)": {
      "ModalDialog.setClosed": "call true" // Call function with arguments
    },      
  }
}

URL pattern

URL patterns are defined as globs, allowing wildcards (*).

Glob Matches
* Any URL.
*.example.com Apex domain and any subdomain, e.g. example.com, www.example.com.
example.com example.org example.com and example.org.
*.example.com/*/about E.g. www.example.com/en/about.

Conditions

Conditions start with if, followed by one or more functions. If all functions evaluate to true, the specified actions are run.

Functions

Function Argument Description
$() Query selector Tests if an HTML element exists.
defined() JavaScript property Tests if a JavaScript property exists.
sleep() Time in milliseconds Returns true after the specified time has passed

Actions

Actions are run when the condition is met, or if no condition is specified.

Functions

Function Argument Description
remove Remove the HTML element.
removeParent Number Remove parent node.
removeIf String Remove the HTML element if its text content matches a string.
addClass Class name Add a class.
removeClass Class name Remove a class.
addStyle Styles Appends CSS to the style attribute.
removeStyle Clears the style attribute.
click Click the HTML element.
call Call the function. Any arguments will be passed to the function.

demodal's People

Contributors

aliasio avatar extrowerk avatar labellson avatar lcomrade avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

demodal's Issues

model overlay on coasttocoastam.com

There's a modal overlay on coasttocoastam.com that demodal doesn't handle.
It blocks page views a couple of seconds after the page loads until clicked.
Pretty annoying, the main reason I picked up your addon.

The majority of assets this page loads come from either iheart.com or adobedtm.com, if that makes any difference.

c2c

The Wall Street Journal

The wall street journal
paywall still there

ex:
https://www.wsj.com
https://www.wsj.com/articles/states-file-new-suits-against-google-over-location-tracking-11643037890

Great addon !

TypeError: node.dataset is undefined

I noticed this extension logs an error whenever an element containing only text is updated.
This issue appears to be Firefox only. I observed this issue in v112.

The problem comes from this section of content.js line 154-156

mutations.every((mutation) =>
  Array.from(mutation.addedNodes).every((node) => node.dataset.demodal)
)

In firefox, when a node containing just text is updated, node.dataset is null, and the attempt to read .demodal causes a type error.

I think the above code could be changed as follows to filter out text-only mutations.

mutations.every((mutation) =>
  Array.from(mutation.addedNodes).every((node) => node.dataset == null || node.dataset.demodal)
)

Here is a minimal html file which triggers the issue once per second.
npx http-server --port 8000 and navigate to http://localhost:8000/issue.html

<html>
<head>
  <script>
    document.addEventListener('DOMContentLoaded', () => {
      const content = document.getElementById("content");
      let count = 0;
      setInterval(() => {
        count++;
        content.innerText = `Some Content ${count}`;
      }, 1000);
    });
  </script>
</head>

<body>
  <div id="content">Some Content 0</div>
</body>
</html>

modal not blocked on celticseasalt.com

The modal on this website isn't being blocked: https://www.celticseasalt.com/
Instructions for replication: Enter the site, wait about 5 seconds, and it pops up.

Screenshot from 2023-07-29 02-31-56

I modified your code you suggested to me from my previous issue into this, but it doesn't remove it:

{
  "celticseasalt.com": {
    "body div[style*='z-index']": "removeIf 'Join'"
  }
}

By the way, is reporting unblocked modals here in the issues page the way we improve Demodal for future versions?

Thanks either way. Cookie and newsletter modals are the bane of my internet experience and your addon helps restore some sanity.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.