{"id":19196998,"url":"https://github.com/jitesoft/node-cookie-sanction","last_synced_at":"2026-05-14T08:43:50.979Z","repository":{"id":30213388,"uuid":"124276960","full_name":"jitesoft/node-cookie-sanction","owner":"jitesoft","description":"Mirror for the cookie-sanction node module.","archived":false,"fork":false,"pushed_at":"2023-01-06T02:08:27.000Z","size":997,"stargazers_count":2,"open_issues_count":12,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-04T10:08:46.744Z","etag":null,"topics":["cookie-consent","cookies","gdpr","javascript","webpack"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jitesoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-07T18:24:31.000Z","updated_at":"2021-03-19T09:23:20.000Z","dependencies_parsed_at":"2023-01-14T16:33:12.872Z","dependency_job_id":null,"html_url":"https://github.com/jitesoft/node-cookie-sanction","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jitesoft%2Fnode-cookie-sanction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jitesoft%2Fnode-cookie-sanction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jitesoft%2Fnode-cookie-sanction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jitesoft%2Fnode-cookie-sanction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jitesoft","download_url":"https://codeload.github.com/jitesoft/node-cookie-sanction/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240271531,"owners_count":19774859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cookie-consent","cookies","gdpr","javascript","webpack"],"created_at":"2024-11-09T12:15:11.785Z","updated_at":"2026-05-14T08:43:45.950Z","avatar_url":"https://github.com/jitesoft.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cookie Sanction / Cookie Consent\r\n\r\nA JavaScript module for front-end cookie consent functionality which allows for loading scripts after consent is \r\naccepted.  \r\nThe dist build is compiled to cover latest browsers while compiling from source with your own tool might be more preferable.  \r\n\r\n## Vanilla js\r\n\r\n### Installation and usage\r\n\r\nInstall the module from any of the standard channels:\r\n\r\n```text\r\nyarn add cookie-sanction\r\nnpm install cookie-sanction --save\r\n```\r\n\r\nInclude it in your own JavaScript as a module\r\n\r\n```javascript\r\nimport { CookieSanction } from 'cookie-sanction';\r\n// alt: { CookieConsent } -\"-\r\n// alt: default\r\n\r\nconst consent = new CookieSanction({\r\n  /* options */\r\n});\r\n\r\ndocument.addEventListener('DOMContentLoaded', () =\u003e {\r\n  consent.active().then((accepted) =\u003e {\r\n    // accepted is true if user accepted, else false.\r\n  }).catch(() =\u003e {\r\n  \r\n  });\r\n});\r\n```\r\n\r\n### Optional arguments\r\n\r\nWhen creating the cookie consent object, you can change a few default values:\r\n\r\n```javascript\r\nconst defaults = {\r\n  element:      'div.cookie-consent', // The element that will toggle hidden or shown.\r\n  cookie:       'accept-cookies',     // Name of the cookie to use.\r\n  cookieValue:  'accepted',           // Cookie value.\r\n  hiddenClass:  'hidden',             // Class to toggle to hide/show the element.\r\n  rejectButton: 'div.cookie-consent button[name=\"reject\"]', // Selector for the button which rejects cookies.\r\n  acceptButton: 'div.cookie-consent button[name=\"accept\"]'  // Selector for the button which accept cookies. \r\n};\r\n```\r\n\r\nJust pass in an object with the properties you wish to change from the default, it will merge the options with the default values.\r\n\r\n## Examples\r\n\r\nCheck the [`example/`](https://gitlab.com/jitesoft/open-source/javascript/cookie-consent/tree/master/example) directory.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjitesoft%2Fnode-cookie-sanction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjitesoft%2Fnode-cookie-sanction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjitesoft%2Fnode-cookie-sanction/lists"}