is-ad
v0.2.1
Published
Function to check if a url contains ads or not.
Downloads
19
Maintainers
Readme
Contains Ads
is-ad is deprecated, please use contains-ads
Function to check if a url contains ads or not.
$ yarn add contains-ads
Basic Example
import { initialize, containsAds } from 'contains-ads';
// Optionally pass the current url for extra precision.
initialize().then(() => {
containsAds('http://www.twitter.com'); // False
containsAds('http://www.blabal.com&ad_type_'); // True
containsAds('http://www.blabal.com&ad_type_', 'sample.com'); // True
});
Advanced Example
import { initialize, containsAds, client } from 'contains-ads';
// You can also parse custom rules. Check the adblock plus docs
// for more information (https://adblockplus.org/filters).
client.parse('||blacklistwebsite.com')
client.parse('@@||whitelistwebsite.com');
initialize().then(() => {
containsAds('http://www.blacklistwebsite.com'); // True
containsAds('http://www.whitelistwebsite.com'); // False
});
Development
# Run tests with mocha.
$ yarn test
# Rebuild the blocker/blocked.txt to a buffer.
$ yarn build:detector