diff --git a/README.md b/README.md index 03f4060..74e021c 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ $ npm install --save adblock-hunter ``` ## Examples +### NPM: ```javascript import { isAdblocking } from 'adblock-hunter' @@ -28,6 +29,27 @@ const someFunction = async () => { } ``` +### Browser +```html + + + + + + + +``` + ## API ### `isAdblocking` `isAdblocking` is a function which makes a call to Google Ads URL and checks wheater the request succeeds (user has no adblock) or not (the adblock is present).\ diff --git a/dist/adblock-hunter.cjs.js b/dist/adblock-hunter.cjs.js index af764a0..693bdd9 100644 --- a/dist/adblock-hunter.cjs.js +++ b/dist/adblock-hunter.cjs.js @@ -60,7 +60,7 @@ var adURL = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'; * Check if AdBlocker is present in user's browser * @return Promise */ -var isAblocking = function () { return __awaiter(void 0, void 0, void 0, function () { +var isAdblocking = function () { return __awaiter(void 0, void 0, void 0, function () { var enabled; return __generator(this, function (_a) { switch (_a.label) { @@ -82,4 +82,4 @@ var isAblocking = function () { return __awaiter(void 0, void 0, void 0, functio }); }); }; -exports.isAblocking = isAblocking; +exports.isAdblocking = isAdblocking; diff --git a/dist/adblock-hunter.es5.js b/dist/adblock-hunter.es5.js index 4d9b563..bd054c4 100644 --- a/dist/adblock-hunter.es5.js +++ b/dist/adblock-hunter.es5.js @@ -56,7 +56,7 @@ var adURL = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'; * Check if AdBlocker is present in user's browser * @return Promise */ -var isAblocking = function () { return __awaiter(void 0, void 0, void 0, function () { +var isAdblocking = function () { return __awaiter(void 0, void 0, void 0, function () { var enabled; return __generator(this, function (_a) { switch (_a.label) { @@ -78,4 +78,4 @@ var isAblocking = function () { return __awaiter(void 0, void 0, void 0, functio }); }); }; -export { isAblocking }; +export { isAdblocking }; diff --git a/dist/adblock-hunter.js b/dist/adblock-hunter.js index 8eab0a9..5890c89 100644 --- a/dist/adblock-hunter.js +++ b/dist/adblock-hunter.js @@ -1 +1 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["adblock-hunter"]={})}(this,function(e){"use strict";function n(e,i,u,c){return new(u=u||Promise)(function(t,n){function o(e){try{a(c.next(e))}catch(e){n(e)}}function r(e){try{a(c.throw(e))}catch(e){n(e)}}function a(e){var n;e.done?t(e.value):((n=e.value)instanceof u?n:new u(function(e){e(n)})).then(o,r)}a((c=c.apply(e,i||[])).next())})}function t(o,r){var a,i,u,c={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]},e={next:n(0),throw:n(1),return:n(2)};return"function"==typeof Symbol&&(e[Symbol.iterator]=function(){return this}),e;function n(t){return function(e){var n=[t,e];if(a)throw new TypeError("Generator is already executing.");for(;c;)try{if(a=1,i&&(u=2&n[0]?i.return:n[0]?i.throw||((u=i.return)&&u.call(i),0):i.next)&&!(u=u.call(i,n[1])).done)return u;switch(i=0,(n=u?[2&n[0],u.value]:n)[0]){case 0:case 1:u=n;break;case 4:return c.label++,{value:n[1],done:!1};case 5:c.label++,i=n[1],n=[0];continue;case 7:n=c.ops.pop(),c.trys.pop();continue;default:if(!(u=0<(u=c.trys).length&&u[u.length-1])&&(6===n[0]||2===n[0])){c=0;continue}if(3===n[0]&&(!u||n[1]>u[0]&&n[1]u[0]&&n[1] */ -declare const isAblocking: () => Promise; -export { isAblocking, }; +declare const isAdblocking: () => Promise; +export { isAdblocking, }; diff --git a/dist/esnext/index.js b/dist/esnext/index.js index 7fa8ff8..73fa570 100644 --- a/dist/esnext/index.js +++ b/dist/esnext/index.js @@ -3,7 +3,7 @@ const adURL = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'; * Check if AdBlocker is present in user's browser * @return Promise */ -const isAblocking = async () => { +const isAdblocking = async () => { let enabled = false; try { await fetch(adURL); @@ -13,5 +13,5 @@ const isAblocking = async () => { } return enabled; }; -export { isAblocking, }; +export { isAdblocking, }; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/esnext/index.js.map b/dist/esnext/index.js.map index a4b3ddf..4a13446 100644 --- a/dist/esnext/index.js.map +++ b/dist/esnext/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,gEAAgE,CAAA;AAE9E;;;GAGG;AACH,MAAM,WAAW,GAAG,KAAK,IAAI,EAAE;IAC7B,IAAI,OAAO,GAAG,KAAK,CAAA;IAEnB,IAAI;QACF,MAAM,KAAK,CAAC,KAAK,CAAC,CAAA;KACnB;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,GAAG,IAAI,CAAA;KACf;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,OAAO,EACL,WAAW,GACZ,CAAA"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,gEAAgE,CAAA;AAE9E;;;GAGG;AACH,MAAM,YAAY,GAAG,KAAK,IAAI,EAAE;IAC9B,IAAI,OAAO,GAAG,KAAK,CAAA;IAEnB,IAAI;QACF,MAAM,KAAK,CAAC,KAAK,CAAC,CAAA;KACnB;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,GAAG,IAAI,CAAA;KACf;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,OAAO,EACL,YAAY,GACb,CAAA"} \ No newline at end of file diff --git a/package.json b/package.json index 2b5c098..ea4274b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "adblock-hunter", - "version": "1.0.0", + "version": "1.0.1", "description": "Detect adblock usage with ease", "main": "dist/adblock-hunter.cjs.js", "module": "dist/adblock-hunter.es5.js", diff --git a/public/index.html b/public/index.html index e69de29..cdbcdf9 100644 --- a/public/index.html +++ b/public/index.html @@ -0,0 +1,35 @@ + + + + + + + Adblock Hunter + + + + +
+

Adblock Hunter

+

+ Detecting.. +

+
+ + + \ No newline at end of file diff --git a/public/styles.css b/public/styles.css new file mode 100644 index 0000000..fbaa275 --- /dev/null +++ b/public/styles.css @@ -0,0 +1,30 @@ +body { + display: flex; + height: 100vh; + box-sizing: border-box; + padding: 20px; + align-items: center; + justify-content: center; + background-color: #0d1117; +} + +h2 { + color: #f0f6fc; + margin-bottom: 10px; + font-size: 36px; + text-align: center; +} + +#results { + font-size: 30px; + color: #f0f6fc; + text-align: center; +} + +.detected { + color: #e92424 !important; +} + +.notDetected { + color: #24b124 !important; +} diff --git a/src/index.ts b/src/index.ts index 110ae56..1526815 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ const adURL = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js' * Check if AdBlocker is present in user's browser * @return Promise */ -const isAblocking = async () => { +const isAdblocking = async () => { let enabled = false try { @@ -17,5 +17,5 @@ const isAblocking = async () => { } export { - isAblocking, + isAdblocking, }