{"id":22409022,"url":"https://github.com/hubspotwebteam/adblock-detect","last_synced_at":"2025-07-31T20:31:06.036Z","repository":{"id":47791930,"uuid":"502075496","full_name":"HubSpotWebTeam/adblock-detect","owner":"HubSpotWebTeam","description":"Script to intercept if common strategies from AD Blockers are detected in the browser.","archived":false,"fork":false,"pushed_at":"2024-01-10T21:12:14.000Z","size":344,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-22T16:47:00.600Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HubSpotWebTeam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-06-10T14:35:02.000Z","updated_at":"2023-08-10T04:41:55.000Z","dependencies_parsed_at":"2024-01-10T16:15:03.665Z","dependency_job_id":"af2f843d-09e5-4933-8899-3f2f8f0293f9","html_url":"https://github.com/HubSpotWebTeam/adblock-detect","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":"0.16666666666666663","last_synced_commit":"69276564e90df0dc73a28c9be0ae5f50927df17f"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpotWebTeam%2Fadblock-detect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpotWebTeam%2Fadblock-detect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpotWebTeam%2Fadblock-detect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HubSpotWebTeam%2Fadblock-detect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HubSpotWebTeam","download_url":"https://codeload.github.com/HubSpotWebTeam/adblock-detect/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228295622,"owners_count":17897596,"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-12-05T12:06:22.043Z","updated_at":"2024-12-05T12:06:22.668Z","avatar_url":"https://github.com/HubSpotWebTeam.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- preset:npm --\u003e\n\u003c!-- project-name:adblocker-detect --\u003e\n\u003c!-- project-title:AdBlocker Detect Script --\u003e\n# AdBlocker Detect Script\n\n\u003c!-- index-start --\u003e\n## Index\n\n- [Development](#development)\n- [How to use it](#how-to-use-it)\n  - [A global variable](#a-global-variable)\n\u003c!-- index-end --\u003e\n## Development\n\nIf you need to build the code for this package, you just need to either run the `npm run build` command, or if you want to build it in watch mode, just run `npm run dev`.\n\n## How to use it\n\nFirst thing is to install the package, as a dependency of your project.\n\n```bash\nnpm install --save @hs-web-team/adblocker-detect\n```\n\nOnce installed you need to simply import the `checkAdblock` function in your module. Here an example:\n\n```javascript\nimport { checkAdblock } from '@hs-web-team/adblocker-detect';\n\n/**\n * Checks the various strategies to detect an AdBlocker\n */\nconst hasAdBlockerWrapper = async () =\u003e {\n  const adblocker = await checkAdblock();\n  if (adblocker) {\n    const adblockerElement = document.createElement('div');\n    adblockerElement.id = 'adblocker-detected';\n    adblockerElement.innerHTML = `\n      \u003cdiv class=\"adblocker-detected\"\u003e\n        \u003ch2\u003eAdblocker detected\u003c/h2\u003e\n        \u003cp\u003e\n          Your browser is blocking ads.\n        \u003c/p\u003e\n      \u003c/div\u003e\n    `;\n    document.body.appendChild(adblockerElement);\n  }\n};\n\nhasAdBlockerWrapper();\n```\n\nAnd that's it, you are good to go!\n\n### A global variable\n\nOnce called for the first time, a global variable is created, which is used to store the state of the results of the checks. You can invoke the state by calling `window.hs_hasAdBlocker`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhubspotwebteam%2Fadblock-detect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhubspotwebteam%2Fadblock-detect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhubspotwebteam%2Fadblock-detect/lists"}