liscap is a library designed to limit the number of listeners on an HTML element. This library helps prevent browser extensions from secretly stealing your data, like login passwords, emails, e.t.c.
To use liscap, you can add the script to the head of your html file:
<script src="https://liscap.vercel.app/liscap.min.js"></script>
// app.js
// liscap is available globally
// Select an element
const element = document.querySelector("button");
// Add event listener
liscap.addEventListener(element, "click", () => console.log("Clicked"));
// Lock listeners
liscap.lock();
// Try adding another listener (will throw an error)
liscap.addEventListener(element, "click", () => console.log("Clicked")); // Error: You can't add more listeners
// Try adding listener directly to the element (will throw an error)
element.addEventListener("click", () => console.log("Clicked")); // Error: Max listeners exceeded
- Description: Add an event listener to an element and limit the number of listeners on the element.
- Parameters:
Name | Type | Description |
---|---|---|
element | HTMLElement or Window or Document | DOM element |
type | String | Event type |
callback | EventListenerOrEventListenerObject | Callback function |
options | Object | Event listener options |
- Returns: void or throws an error
- Type: void | Error
- Description: Lock the instance to prevent adding more listeners. Note: This is a one-time operation and can't be undone.
- Returns: void
- Description: Remove an event listener from an element and decreases the number of listeners on the element.
- Parameters:
Name | Type | Description |
---|---|---|
element | HTMLElement or Window or Document | DOM element |
type | String | Event type |
callback | EventListenerOrEventListenerObject | Callback function |
options | Object | Event listener options |
- Returns: void or throws error
- Type: void | Error
- Description: Check if the liscap instance is active.
- Returns: void
- Version: 1.0.0
- Since: 1.0.0
- Author: Benedict Gabriel
This project is licensed under the MIT License. See the LICENSE file for details.
The source code for this library can be found in liscap.js