{"id":20514215,"url":"https://github.com/webreflection/cookies-monster","last_synced_at":"2025-06-28T11:32:33.232Z","repository":{"id":65993138,"uuid":"39060007","full_name":"WebReflection/cookies-monster","owner":"WebReflection","description":"A Simplified EU Cookie Law Approach","archived":false,"fork":false,"pushed_at":"2015-07-21T17:24:36.000Z","size":828,"stargazers_count":32,"open_issues_count":0,"forks_count":2,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-05T23:15:29.694Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://webreflection.github.io/cookies-monster/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WebReflection.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-14T07:16:11.000Z","updated_at":"2019-10-29T13:07:05.000Z","dependencies_parsed_at":"2023-02-19T21:00:43.249Z","dependency_job_id":null,"html_url":"https://github.com/WebReflection/cookies-monster","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/WebReflection/cookies-monster","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fcookies-monster","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fcookies-monster/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fcookies-monster/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fcookies-monster/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebReflection","download_url":"https://codeload.github.com/WebReflection/cookies-monster/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fcookies-monster/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262421822,"owners_count":23308520,"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":[],"created_at":"2024-11-15T21:15:20.282Z","updated_at":"2025-06-28T11:32:33.213Z","avatar_url":"https://github.com/WebReflection.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"cookies-monster\n===============\n\n[![build status](https://secure.travis-ci.org/WebReflection/cookies-monster.svg)](http://travis-ci.org/WebReflection/cookies-monster)\n\n# A Simplified EU Cookie Law Approach\n\nThe aim of this project is to simplify through an agnostic, drop in based approach, the handling of the infamous EU Cookie banner.\nSupporting separation of concerns, this project offers an extremely compact and widely compatible JavaScript logic\nwhich will take care of:\n\n  * showing the banner only if the user has not accepted it explicitly\n  * disappearing on scroll automatically after at least 3 seconds\n  * adding and removing CSS classes to give Web Developers full style-ability\n  * cookie for a year, renewed each time ( forever accepted )\n\nFollowing an example on how to use files provided in the [./build](build/) folder.\n\n\n\n### The JS part\n\nWhenever a user clicks `Accept`, the banner disappears for a year and for the whole domain.\n\nIt also disappears, after about 3 seconds, as soon as the user scrolls the page.\nHowever, in latter case, it will be shown next time, unless the user made an explicit choice through the `Accept` button.\n\n\n\n### The CSS part\n\nThe [current file](src/cookies-monster.css) is just an example of how such banner could be styled.\nBe sure you have defined both `#cookies-monster` and `#cookies-monster.hidden` behaviors, and feel free to style its optional link element which by default should have  a `.cookies-monster-accepted` class.\n\n\n\n### The HTML part\n\nIt can be anything you want, as long as the container id is `cookies-monster`. You might need to specify a link to know more.\nPlease be sure what you provide is useful and meaningful enough, accordingly with the law expectations.\nJust as basic example, this is a generic element.\n\n```html\n\u003cdiv id=\"cookies-monster\" class=\"hidden\"\u003e\n  This sites uses cookies. \u003ca\n    class=\"cookies-monster-accepted\"\n    href=\"#cookies-monster\"\n  \u003eAccept\u003c/a\u003e\n\u003c/div\u003e\n```\n\nBy default, the element should contain the class `hidden` plus eventually others.\n\n**Please note** that if an element with class `.cookies-monster-accepted` is present, this will be used to set the cookie once clicked.\n\n\n\n### How To\n\nFollowing is the most basic layout you need. The script is not obtrusive and it can work within any layout already in production.\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003clink rel=\"styleSheet\"\n      href=\"//cdnjs.cloudflare.com/ajax/libs/cookies-monster/0.1.4/cookies-monster.css\"\u003e\n    \u003cscript async\n      src=\"//cdnjs.cloudflare.com/ajax/libs/cookies-monster/0.1.4/cookies-monster.js\"\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003cdiv id=\"cookies-monster\" class=\"hidden\"\u003e\n      This sites uses cookies. \u003ca\n        class=\"cookies-monster-accepted\"\n        href=\"#cookies-monster\"\n      \u003eAccept\u003c/a\u003e\n    \u003c/div\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\nYou can see a [live working example here](http://webreflection.github.io/cookies-monster/test/test.html)\n\nFinally, a mandatory **special thanks to [cdnjs](https://cdnjs.com/)** for hosting this little js and css script.\n\n\n\n### License\n\nThis project comes with a [WTFPL License](http://www.wtfpl.net/).\n\n\n\n### Compatibility\n\nThe script is compatible with every Mobile and Desktop browser.\nIf you want to support IE9 and/or eventually IE8 too, use these comments on top of your pages head.\n\n```html\n\u003c!--[if lte IE 9]\u003e\u003cstyle\u003elabel{display:block !important;}\u003c/style\u003e\u003cscript\u003e(function(f){window.setTimeout=f(window.setTimeout);window.setInterval=f(window.setInterval)})(function(f){return function(c,t){var a=[].slice.call(arguments,2);return f(function(){c.apply(this,a)},t)}});\u003c/script\u003e\u003c![endif]--\u003e\n\u003c!--[if IE 8]\u003e\u003cscript src=\"//cdnjs.cloudflare.com/ajax/libs/ie8/0.2.5/ie8.js\"\u003e\u003c/script\u003e\u003c![endif]--\u003e\n```\n\nAfter that you can include the script either deferred or async or however you like.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebreflection%2Fcookies-monster","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebreflection%2Fcookies-monster","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebreflection%2Fcookies-monster/lists"}