Skip to content

Commit

Permalink
Fixed typo in the function name
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaumaus committed Jan 27, 2022
1 parent ca41916 commit 5cd5690
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 13 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ $ npm install --save adblock-hunter
```

## Examples
### NPM:
```javascript
import { isAdblocking } from 'adblock-hunter'

Expand All @@ -28,6 +29,27 @@ const someFunction = async () => {
}
```

### Browser
```html
<head>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/Blaumaus/adblock-hunter/dist/adblock-hunter.js" defer></script>
</head>
<body>
<script>
document.addEventListener('DOMContentLoaded', () => {
const { isAdblocking } = window['adblock-hunter']
isAdblocking().then(res => {
if (res) {
// Adblock Detected
}
})
})
</script>
</body>
</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).\
Expand Down
4 changes: 2 additions & 2 deletions dist/adblock-hunter.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean>
*/
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) {
Expand All @@ -82,4 +82,4 @@ var isAblocking = function () { return __awaiter(void 0, void 0, void 0, functio
});
}); };

exports.isAblocking = isAblocking;
exports.isAdblocking = isAdblocking;
4 changes: 2 additions & 2 deletions dist/adblock-hunter.es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean>
*/
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) {
Expand All @@ -78,4 +78,4 @@ var isAblocking = function () { return __awaiter(void 0, void 0, void 0, functio
});
}); };

export { isAblocking };
export { isAdblocking };
2 changes: 1 addition & 1 deletion dist/adblock-hunter.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/esnext/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
* Check if AdBlocker is present in user's browser
* @return Promise<Boolean>
*/
declare const isAblocking: () => Promise<boolean>;
export { isAblocking, };
declare const isAdblocking: () => Promise<boolean>;
export { isAdblocking, };
4 changes: 2 additions & 2 deletions dist/esnext/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/esnext/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
35 changes: 35 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Adblock Hunter</title>
<link rel="stylesheet" href="styles.css"></link>
<script type="text/javascript" src="../dist/adblock-hunter.js" defer></script>
</head>
<body>
<div>
<h2>Adblock Hunter</h2>
<p id="results">
Detecting..
</p>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const { isAdblocking } = window['adblock-hunter']
const results = document.querySelector('#results')

isAdblocking().then(res => {
if (res) {
results.classList.add('detected')
results.textContent = 'Adblock usage detected!'
} else {
results.classList.add('notDetected')
results.textContent = 'You are not using an Adblock :)'
}
})
})
</script>
</body>
</html>
30 changes: 30 additions & 0 deletions public/styles.css
Original file line number Diff line number Diff line change
@@ -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;
}
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean>
*/
const isAblocking = async () => {
const isAdblocking = async () => {
let enabled = false

try {
Expand All @@ -17,5 +17,5 @@ const isAblocking = async () => {
}

export {
isAblocking,
isAdblocking,
}

0 comments on commit 5cd5690

Please sign in to comment.