1.0.2 • Published 4 years ago

@anowlet/cookie-consent v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Cookie Consent

A Simple Cookie Consent Manager

Actions Status styled with prettier tested with jest Commitizen friendly semantic-release

It is a Javascript based solution for blocking / allowing even 3rd party cookies to comply with GDPR & CCPA.

demo

Feature

  • Support PC and mobile cookie banner display, responsive
  • Lifecycle hooks, giving users the opportunity to add your own code at specific stages
  • Multi-lingual, supports EU language
  • Support removing unwanted cookies
  • Users can customize whether the country complies with CCPA & GDPR
  • Support different UA whether to display cookie banner
  • Hosted on AWS Cloudfront with edges around the globe for
  • Four different blocking methods

Dynamic script tags

Some services insert dynamically created script tags to the HEAD at page load. These can be intercepted and blocked.

Script tag blocking

Some third party services require you to insert a script tag into your HTML pages. These can be inactivated until the user allowes them.

Script wrapping

Some services are not inserted in a SCRIPT tag and are obscured by layers of other code. Thats why this script creates a global wrapper function what you can use to wrap and blovk any JS code.

Local cookies

Finally the local cookies set on your domain can be also filtered by overriding the bowsers COOKIE SET method.

Usage

Module

import CookieConsent from 'cookie-consent';
// or
const CookieConsent = require('cookie-consent');

Classic

<!-- Specify the version -->
<script src="./cookie-consent.umd.js"></script>
<script>
  var CookieConsent = window.CookieConsent;
</script>

Initialization

var cc = new CookieConsent({
  //...options,
});

Configuration Options

  new CookieConsent({
    language: 'en',
  });
  </script>

Instance Methods

Events

cc.on('initialized', (...args) => console.log(args));
cc.on('error', console.error);
cc.on('popupOpened', () => console.log('Popup Open'));
cc.on('popupClosed', () => console.log('Popup Closed'));
cc.on('modalOpened', () => console.log('Modal Open'));
cc.on('modalClosed', () => console.log('Modal Closed'));
cc.on('statusChanged', (...args) => console.log(args));

Browsers support

IE / EdgeFirefoxChromeSafariiOS Safari
IE11, Edgelast 2 versionslast 2 versionslast 2 versionslast 2 versions

NPM scripts

  • npm t: Run test suite
  • npm start: Run npm run build in watch mode
  • npm run test:watch: Run test suite in interactive watch mode
  • npm run test:prod: Run linting and generate coverage
  • npm run build: Generate bundles and typings, create docs
  • npm run lint: Lints code
  • npm run commit: Commit using conventional commit style (husky will tell you to use it if you haven't :wink:)

Automatic releases

FAQ

Contributions of any kind are welcome!