How to initialize a web plugin (DarkReader) into my html document?

Viewed 136

I'm trying to import the 'enable' method from the 'DarkReader' plugin. I'm not so familiar with the JavaScript plugin initialization process in an HTML document.

I opened a tag in the ending of the tag, the source of it directs to the plugin web hosting url.

and inside that, I tried to initialize it with this script:

<script src="https://unpkg.com/darkreader">

      import {
          enable as enableDarkMode,
          disable as disableDarkMode,
      } from 'darkreader';

    </script>

    <button id="tt" onclick="enableDarkMode({
          brightness: 100,
          contrast: 90,
          sepia: 10,
      });">
      CLICK
    </button>```

Can someone explain how to do that?
1 Answers

Write it like that

<script src="https://cdn.jsdelivr.net/npm/darkreader/darkreader.min.js" crossorigin="anonymous"></script>
<script type="text/javascript">
    DarkReader.enable({
        brightness: 100,
        contrast: 90,
        sepia: 10
        });
</script>
Related