npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cookierazzi

v1.1.0

Published

Cookie Consent Management Plateform (CMP)

Downloads

3

Readme

CookieRazzi : A Cookie Concent Management Plateform (CMP)

CookieRazzi

Support IE11 npm NPM

Features

  • Written in vanilla javascript, no dependencies needed
  • Clean UI with some customisable style (CSS custom properties)
  • Change the markup of RGPD-sensitive JavaScript script tags to run only if the user has given consent.
  • The expiration time of the cookie storing user consent preferences is configurable. By default it is one month.

How to use

<link rel="stylesheet" href="cookierazzi.css">
<script src="cookierazzi.js"></script>
<script type="text/javascript">
    var cmp = new cookieRazzi;

    cmp.setExpire(2);
    cmp.setSeed(2);
    cmp.setText({title : 'Cookie policy'});
    cmp.updateConsent('necessary', {title: "Lorem ipsum"});
    cmp.addConsent( 'tracking' : {
        disabled : false,
        value : true,
        icon : "https://www.google.com/s2/favicons?domain=analytics.google.com",
        title : "",
        text :  "Description",
        callback: function(consentValue){
            //...
        }
    });

    document.addEventListener("DOMContentLoaded", function() {
        cmp.init();
    });
</script>

<script type="text/plain" cookie-consent="tracking">
    console.log('Eval script text/plain if consent');
</script>

Customise sentences

Texts parameters

| key | Default Sentences (string) | | -----: | ----- | | title | "Nous respectons votre vie privée" | | intro | "Nous utilisons des cookies pour améliorer et personnaliser votre expérience." | | desc | "Vous pouvez à tout moment revenir sur vos choix en utilisant le lien « paramétrer les cookies sur ce site » disponible dans notre politique de confidentialité" | | reject_all | "Tout refuser" | | accept | "Valider la sélection" | | accept_all | "J'accepte tout" |

Methods

| Method | Type | Description | | -----: | ----- | ----- | | init() | | Initialize the CMP | | debug() | | Log settings and CMP cookie | | showPopup() | | Show CMP popup | | hidePopup() | | Hide CMP Popup | | setSeed() | string | Change the seed if consents are added or modified to reset the cookie | | setExpire() | int | Set the expiration time for the cookie that retains user consent preferences. By default it is one month. | | setText() | object | Customise popup sentences | | addConsent() | (string,object) | Add consent with a named key and object with its value | | updateConsent() | (string,object) | Update consent with the named key of the consent to be updated and an object containing the new values |

Consents

| key | Type | Description | | -----: | ----- | ----- | | disabled | bool | Disabled the checkbox of the consent | | value | bool | Default value of the consent | | icon | url, base64 image, false | For better acceptance, accompany the consent with an icon. (16x16) | | title | string | Title of the consent | | text | string | Description of the consent | | callback | function | Function used if consent is approved |

Toggle popup

In order to open the popup again, add the class show-cmp on a link, button, or other. When clicked, the popup will appear.

<a href="#" class="show-cmp">Manage cookies</a>

Customise

the CMP can be customised using a few CSS variables. Here are the default values:

:root{
	--cmp-sun-color: #fff6a2;
	--cmp-btn-bg-hover: #fff6a2;
	--cmp-btn-color-hover: #333333;
	--cmp-radius: 8px;
}

Example : Gtag setup

<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXX-X"></script>
<script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}

    gtag("consent", "default", {
        ad_storage: "denied",
        analytics_storage: "denied",
        wait_for_update: 1000 // ms
    });
    
    gtag("set", "ads_data_redaction", true);
    gtag('js', new Date());
    gtag('config', 'UA-XXXXX-X');
    
    function updateConsent(ad_storage, analytics_storage) {
        gtag("consent", "update", {
            analytics_storage: analytics_storage ? "granted" : "denied"
        });
    }
</script>
<link rel="stylesheet" type="text/css" href="cookierazzi.css"/>
<script src="cookierazzi.js" type=""></script>
<script>
    var cmp = new cookieRazzi;
    cmp.addConsent('tracking', {
        disabled : false,
        value : true,
        icon : "https://www.google.com/s2/favicons?domain=analytics.google.com",
        title : "Tracking",
        text :  "Description",
        callback: function(consentValue){
            updateConsent(consentValue, consentValue)
        }
    });
    document.addEventListener("DOMContentLoaded", function() {
        cmp.init();
    });
</script>

Legal information

Visuel de Cookie créé par freepik - fr.freepik.com