Skip to content

Level222/copyable

Repository files navigation

Copyable

Browser extension to unblock copying of web pages

Usage

It's simple. Open the options page and edit the patterns property.

Examples:

  {
    "patterns": [
+     "https://example.com/*",
      // Matches `https://example.com` and `https://example.com/path/to/file`

+     "*://example.com/path",
      // Matches `http://example.com/path` and `https://example.com/path`

+     "https://*.example.com/"
      // Matches `https://example.com` and `https://www.example.com/`
    ],
    // Other options...
  }

How This Works

  • Force user-select: auto.

    Examples of what this will unblock:

    <p style="user-select: none;">Hello</p>
  • Wrap Event.prototype.preventDefault by Proxy.

    Examples of what this will unblock:

    <p>Hello</p>
    <script>
      document.querySelector('p').addEventListener('selectstart', (event) => {
        event.preventDefault();
      });
      // or
      document.querySelector('p').onselectstart = (event) => {
        event.preventDefault();
      };
    </script>
    <!-- or -->
    <p onselectstart="arguments[0].preventDefault();">Hello</p>
  • Wrap setters for all event handlers (e.g., onselectstart) for Node subtype prototypes and window by Proxy.

    Examples of what this will unblock:

    <p>Hello</p>
    <script>
      document.querySelector('p').onselectstart = () => {
        return false;
      };
    </script>
  • Calls wrapped setters to inline event handlers when elements are added or attributes are changed.

    Examples of what this will unblock:

    <p onselectstart="return false;">Hello</p>

Options

patterns

Type: string[]

Default: []

Match patterns for webpages to unblock copying.

Learn more about match patterns on mdn web docs or Chrome for Developers.

To activate it on a new page, the page must be reloaded.

eventTypes

Type: string[]

Default: src/default-storage/index.ts

Event types to unblock copying.

Changes to this option are reflected immediately on the page.

css

Type: string

Default: src/default-storage/style.css

CSS styles to be inserted.

Changes to this option are reflected immediately on the page.

cssOrigin

type: 'USER' | 'AUTHOR'

Default: 'USER'

An origin type of css to be inserted.

Learn more about origin types.

About

Browser extension to unblock copying of web pages

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors