New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@hs-web-team/adblocker-detect

Package Overview
Dependencies
Maintainers
45
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hs-web-team/adblocker-detect - npm Package Compare versions

Comparing version

to
1.0.0

dist/index.d.ts

2

dist/index.js

@@ -1,1 +0,1 @@

(()=>{"use strict";var n=function(n,t,e,o){return new(e||(e=Promise))((function(i,c){function d(n){try{r(o.next(n))}catch(n){c(n)}}function a(n){try{r(o.throw(n))}catch(n){c(n)}}function r(n){var t;n.done?i(n.value):(t=n.value,t instanceof e?t:new e((function(n){n(t)}))).then(d,a)}r((o=o.apply(n,t||[])).next())}))};window.hs_hasAdBlocker=!1,function(){(()=>{var t,e,o,i;t=this,e=void 0,i=function*(){const t=yield n(void 0,void 0,void 0,(function*(){const t=yield n(void 0,void 0,void 0,(function*(){let n=!1;try{yield fetch("https://www3.doubleclick.net",{method:"HEAD",mode:"no-cors",cache:"no-store"})}catch(t){n=!0}return n})),e=yield n(void 0,void 0,void 0,(function*(){const n="hs-bait-notify",t=document.createElement("div");t.id=n;const e=document.createElement("div");return e.classList.add("ads","ad","banner","ad-banner","ad-banner-top"),e.style.width="1px",e.style.height="1px",t.appendChild(e),document.body.appendChild(t),new Promise((t=>{setTimeout((()=>{const e=document.getElementById(n);return t(!e)}),1e3)}))}));return t||e}));window.hs_hasAdBlocker=t},new((o=void 0)||(o=Promise))((function(n,c){function d(n){try{r(i.next(n))}catch(n){c(n)}}function a(n){try{r(i.throw(n))}catch(n){c(n)}}function r(t){var e;t.done?n(t.value):(e=t.value,e instanceof o?e:new o((function(n){n(e)}))).then(d,a)}r((i=i.apply(t,e||[])).next())}))})()}()})();
(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{checkAdblock:()=>i});var n=function(e,t,n,o){return new(n||(n=Promise))((function(i,c){function d(e){try{a(o.next(e))}catch(e){c(e)}}function r(e){try{a(o.throw(e))}catch(e){c(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(d,r)}a((o=o.apply(e,t||[])).next())}))};let o=!1;window.hs_hasAdBlocker=o;const i=()=>{return e=void 0,t=void 0,c=function*(){return o=yield n(void 0,void 0,void 0,(function*(){const e=yield n(void 0,void 0,void 0,(function*(){let e=!1;try{yield fetch("https://www3.doubleclick.net",{method:"HEAD",mode:"no-cors",cache:"no-store"})}catch(t){e=!0}return e})),t=yield n(void 0,void 0,void 0,(function*(){const e="hs-bait-notify",t=document.createElement("div");t.id=e;const n=document.createElement("div");return n.classList.add("ads","ad","banner","ad-banner","ad-banner-top"),n.style.width="1px",n.style.height="1px",t.appendChild(n),document.body.appendChild(t),new Promise((t=>{setTimeout((()=>{const n=document.getElementById(e);return t(!n)}),1e3)}))}));return e||t})),window.hs_hasAdBlocker=o,o},new((i=void 0)||(i=Promise))((function(n,o){function d(e){try{a(c.next(e))}catch(e){o(e)}}function r(e){try{a(c.throw(e))}catch(e){o(e)}}function a(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(d,r)}a((c=c.apply(e,t||[])).next())}));var e,t,i,c};module.exports=t})();
{
"name": "@hs-web-team/adblocker-detect",
"version": "0.2.2",
"version": "1.0.0",
"description": "Script to detect the presence of AdBlockers",
"repository": "MarketingWebTeam/adblock-detect",
"main": "dist/index.js",
"main": "./dist/index.js",
"engines": {

@@ -16,3 +16,3 @@ "node": ">=14.0.0"

"prepare": "npm run build",
"build": "webpack --config webpack.config.js",
"build": "rm -Rf dist/ && webpack --config webpack.config.js",
"dev": "webpack --config webpack.config.js --watch",

@@ -26,7 +26,9 @@ "eslint": "eslint --ext .js,.ts src",

"files": [
"src/lib/adblock.ts"
"/dist"
],
"types": "dist/index.d.ts",
"author": "@MarketingWebTeam/webapps",
"license": "ISC",
"devDependencies": {
"@types/node": "^17.0.31",
"@typescript-eslint/eslint-plugin": "^5.19.0",

@@ -36,2 +38,3 @@ "@typescript-eslint/parser": "^5.19.0",

"ts-loader": "^9.2.8",
"tslib": "^2.4.0",
"typescript": "^4.6.3",

@@ -38,0 +41,0 @@ "webpack": "^5.72.0",

@@ -21,2 +21,44 @@ <!-- preset:npm -->

## How to use it
First thing is to install the package, as a dependency of your project.
```bash
npm install --save @hs-web-team/adblocker-detect
```
Once installed you need to simply import the `checkAdblock` function in your module. Here an example:
```javascript
import { checkAdblock } from '@hs-web-team/adblocker-detect';
/**
* Checks the various strategies to detect an AdBlocker
*/
const hasAdBlockerWrapper = async () => {
const adblocker = await checkAdblock();
if (adblocker) {
const adblockerElement = document.createElement('div');
adblockerElement.id = 'adblocker-detected';
adblockerElement.innerHTML = `
<div class="adblocker-detected">
<h2>Adblocker detected</h2>
<p>
Your browser is blocking ads.
</p>
</div>
`;
document.body.appendChild(adblockerElement);
}
};
hasAdBlockerWrapper();
```
And that's it, you are good to go!
### A global variable
Once 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`.
<!-- deployment/npm-start -->

@@ -23,0 +65,0 @@ ## How to publish an npm package