Skip to content

This is an experimental library to prevent browser extensions from harvesting confidential information by limiting the amount of listeners that can be placed on an element.

Notifications You must be signed in to change notification settings

benhexie/liscap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

liscap

Description

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.

Usage

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>

Example

// 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

API

Methods

addEventListener(element, type, callback, options) → {void|Error}

  • 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

lock() → {void}

  • Description: Lock the instance to prevent adding more listeners. Note: This is a one-time operation and can't be undone.
  • Returns: void

removeEventListener(element, type, callback, options) → {Number}

  • 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

sayHello() → {void}

  • Description: Check if the liscap instance is active.
  • Returns: void

Version

  • Version: 1.0.0
  • Since: 1.0.0

Author

License

This project is licensed under the MIT License. See the LICENSE file for details.

Source

The source code for this library can be found in liscap.js

About

This is an experimental library to prevent browser extensions from harvesting confidential information by limiting the amount of listeners that can be placed on an element.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published