{"id":18353360,"url":"https://github.com/philippg777/cookieyesno","last_synced_at":"2025-04-06T12:31:38.092Z","repository":{"id":36685654,"uuid":"229456049","full_name":"philippG777/cookieyesno","owner":"philippG777","description":"Easy to use GDPR-compliant cookie-banner","archived":false,"fork":false,"pushed_at":"2022-11-10T18:26:33.000Z","size":277,"stargazers_count":4,"open_issues_count":5,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T22:41:32.486Z","etag":null,"topics":["banner","consent","cookie-banner","cookie-banner-javascript","cookie-banners","cookie-consent","cookie-law","gdpr","gdpr-compliant","gdpr-consent","gdpr-cookie","gdpr-cookies","hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/philippG777.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":"2019-12-21T16:46:25.000Z","updated_at":"2023-02-28T15:31:01.000Z","dependencies_parsed_at":"2023-01-17T04:03:21.496Z","dependency_job_id":null,"html_url":"https://github.com/philippG777/cookieyesno","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philippG777%2Fcookieyesno","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philippG777%2Fcookieyesno/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philippG777%2Fcookieyesno/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philippG777%2Fcookieyesno/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philippG777","download_url":"https://codeload.github.com/philippG777/cookieyesno/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247484260,"owners_count":20946384,"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":["banner","consent","cookie-banner","cookie-banner-javascript","cookie-banners","cookie-consent","cookie-law","gdpr","gdpr-compliant","gdpr-consent","gdpr-cookie","gdpr-cookies","hacktoberfest"],"created_at":"2024-11-05T21:39:18.333Z","updated_at":"2025-04-06T12:31:35.819Z","avatar_url":"https://github.com/philippG777.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CookieYesNo\n## An easy to use GDPR-compliant cookie-banner\n![Cookiebanner Screenshot](screenshot.png)\n\n \t\n\u0026#9989; GDPR-complient\n\n\u0026#9989; Easy to Use\n\n\u0026#9989; Mobile friendly\n\n\u0026#9989; Small memory footprint\n\n\u0026#9989; Highly customizable\n\n## Usage\nThe banner on the screenshot above has been created using only the 14 lines you can see below.\n\n```js\nvar cyn = new CookieYesNo({\n  categories: {\n    required: {\n      name: 'Required cookies',\n      description: 'These cookies are necessary for the website to function properly',\n      accepted: true,\n      changeable: false\n    },\n    analytics: {\n      name: 'Web analytics',\n      description: 'These cookies are used to analyze the user\\'s behavior.'\n    }\n  }\n});\n```\n\n## Documentation\n### Configuration\nThe configuration is the only argument of `new CookieYesNo(config)` and is a map, The following things can / have to be configured:\n\n* `categories` *(Map)* **Required » Take a look at the [category configuration](#category-configuration)**\n* `text` *(Map) [optional]* [Link placeholders](#link-placeholders) can be used\n  * `above` *(String) [optional]* Text above the section where the user can select specific cookie-categories\n  * `below` *(String) [optional]* Text below the section where the user can select specific cookies\n* `title` *(String) [optional - by default \"Cookie Settings\"]* Title of the banner \n* `acceptAllButtonText` *(String) [optional - by default \"Accept all cookies\"]* Text of the button that's for accepting all cookies\n* `acceptSelectionButtonText` *(String) [optional - by default \"Accept selected cookies\"]* Text of the button that's for accepting only selected cookie categories\n* `privacyPolicy` *(Map) [optional]*\n  * `url` *(String)* URL of your privacy policy (in case the banner covers the link on the actual page)\n  * `text` *(String)* Text of the link\n* `cookiePolicy` *(Map) [optional]*\n  * `url` *(String)* URL of your cookie policy (String)\n  * `text` *(String)* Text of the link\n* `imprint` *(Map) [optional]*\n  * `url` *(String)* URL of your imprint (required in case that the banner covers the link on the actual page)\n  * `text` *(String)* Text of the link\n* `version` *(String) [optional]* Version of the configuration - if you change the version - the user has to consent again (for the case that you change something in the categories) - Use any text you like to, I recommed the date of the change. If not version has been set before, the user also give his consent again.\n\n### Category configuration\nEach cookie category is an item in the `categories`-Map.\nHere a short example:\n```js\ncategories: {\n  required: {\n    name: 'Required cookies',\n    accepted: true,          // preselected\n    description: 'These cookies are necessary for the website to function properly.',\n    changeable: false       // user can not change this option\n  },\n  analytics: {\n    name: 'Web Analytics',\n    description: 'These cookies are used to analyze the user\\'s behavior.'\n  }\n}\n```\n\n#### Configuration possibilities of a category\n* `name` *(String)* **Required** Name/Title of the cookie category\n* `description` *(String)* **Required** Description of the cookie category\n* `accepted` *(Boolean) [optional - by default false]* If the category is preselected\n* `changeable` *(Boolean) [optional - by default true]* If the user can change the value\n* `reloadOnReject` *(Boolean) [optional - by default true]* If the page is reloaded if the cookie category gets rejected - We need to do this to stop scripts from running that would set cookies.\n* `onAccept` *(Array) [optional - by default []]* Shortcut for [Events](#events)\n* `onReject` *(Array) [optional - by default []]* Shortcut for [Events](#events)\n* `onChange` *(Array) [optional - by default []]* Shortcut for [Events](#events)\n\n### Script blocking\n#### Blocking external scripts\nYou have to replace `src` with `data-cyn-src` and have to set the `type` to `text/plain`. The `data-cyn-require` attribute specifies which cookie category has to be allowed to run the script. So `analytics` has to be the key of the Web Analytics category in the `categories` map.\n```html\n\u003cscript type=\"text/plain\" data-cyn-src=\"analytics.js\" data-cyn-require=\"analytics\"\u003e\u003c/script\u003e\n```\n#### Blocking inline scripts\n**Caution: May not block the execution of the script in older Firefox versions!  External script blocking (above) is safe to use as well as Events (below). Use these medthods instead.**\nThe `type` attribute has to be set to `text/plain`. The script will be executed when the category with the key `analytics` is allowed.\n```html\n\u003cscript type=\"text/plain\" data-cyn-require=\"analytics\"\u003e\n  // YOUR CODE HERE\n\u003c/script\u003e\n```\n\n### Events\nNote: the `category` argument in the methods below is the key of the specific category in the `categories` map in the configuration map.\n#### `onAccept(category, callback)`\nCallback function gets executed when the specified category gets acceped.\n#### `onReject(category, callback)`\nCallback function gets executed when the specified category gets rejected. Explicitly return `false` if you don't want to reload the site. This can also be done by the config. If you like to reload the page either return nothing or return `true`.\n#### `onChange(category, callback)`\nCallback function gets executed when the specified category gets changed. The first argument of the `callback` function is a *Boolean* that states if the category has been accepted *(true)* or rejected *(false)*.\n\n\nFirst the `onChange` callbacks are executed, then the scripts are activated if necessary and then `onAccept` and `onReject` callbacks are executed. \n\n### Other methods\n#### `getSettings()`\nGet the current cookie settings as a *map*.\n#### `reviewSettings()`\nLet the user review his consent.\n#### `show()`\nShow the cookie banner.\n#### `hide()`\nHide the cookie banner.\n\n### Link placeholders\nLink placeholders can be used in the `text.above` and `text.below`.\nSimply put `PRIVACY_POLICY`, `COOKIE_POLICY`, or `IMPRINT` in the String.\nThese will be replaced with the matching links. Note: In order to use this feature you have to specify the links in the configuration.\n\n### Modify the banner\nIt's pretty simple: just use CSS-rules.\nThe following classes are available:\n\n* `.cyn-banner`: main banner element\n* `.cyn-categories`: table containing the different cookie categories\n* `.cyn-btn-save`: save settings button \n* `.cyn-btn-accept-all`: accept all button\n\n---\nBased on https://github.com/rollup/rollup-starter-app and https://github.com/rollup/rollup-starter-lib (both MIT License) Take a look at LICENSE_ROLLUP_STARTER_APP and LICENSE_ROLLUP_STARTER_LIB.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilippg777%2Fcookieyesno","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilippg777%2Fcookieyesno","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilippg777%2Fcookieyesno/lists"}