Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/igorskyflyer/npm-adblock-header-extract
โ๏ธ An npm module that provides ways to extract header and metadata from an Adblock filter file. ๐
https://github.com/igorskyflyer/npm-adblock-header-extract
adblock back-end biome data filter header igorskyflyer javascript js metadata node nodejs npm string ts typescript utility
Last synced: 2 days ago
JSON representation
โ๏ธ An npm module that provides ways to extract header and metadata from an Adblock filter file. ๐
- Host: GitHub
- URL: https://github.com/igorskyflyer/npm-adblock-header-extract
- Owner: igorskyflyer
- License: mit
- Created: 2024-07-15T16:05:53.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-07-15T17:25:48.000Z (4 months ago)
- Last Synced: 2024-11-02T23:06:10.629Z (5 days ago)
- Topics: adblock, back-end, biome, data, filter, header, igorskyflyer, javascript, js, metadata, node, nodejs, npm, string, ts, typescript, utility
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@igor.dvlpr/adblock-header-extract
- Size: 85.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
Adblock header extract
โ๏ธ An npm module that provides ways to extract header and metadata from an Adblock filter file. ๐
๐ Support further development
I work hard for every project, including this one and your support means a lot to me!
Consider buying me a coffee. โ
Thank you for supporting my efforts! ๐๐
@igorskyflyer
## ๐ต๐ผ Usage
Install it by executing:
```shell
npm i "@igor.dvlpr/adblock-header-extract"
```
## ๐คน๐ผ API
```ts
function extractHeaderString(
filter: string,
trimWhitespace: boolean = true
): string
```Extracts the header and metadata from an Adblock filter text.
- `filter` - the string that contains the Adblock filter,
- `trimWhitespace` - should the whitespace be trimmed or not. Defaults to `true`.> Returns the extracted header.
---
```ts
function extractHeaderString(
filter: string,
trimWhitespace: boolean = true
): string
```Extracts the header and metadata from an Adblock filter file. File is read with the `UTF-8` encoding by default.
- `file` - the path to the filter file,
- `trimWhitespace` - should the whitespace be trimmed or not. Defaults to `true`.
> [!CAUTION]
> Will throw an error if the file cannot be found or there is an error in reading it.
>
> Returns the extracted header.
---
## โจ Example
`./example.ts`
```ts
import { extractHeaderFromFile, extractHeaderString } from '@igor.dvlpr/adblock-header-extract'console.log(extractHeaderFromFile('./filter.txt'))
// will print
/*
[Adblock Plus 2.0]
!
! ___ __ _ __ _ __
! / | ____/ / | | / /____ (_)____/ /
! / /| | / __ / | | / // __ \ / // __ /
! / ___ |/ /_/ / | |/ // /_/ // // /_/ /
! /_/ |_|\____/ |___/ \____//_/ \____/
!
!
! {@!}
! Title: AdVoid.Full
! Description: Blocks major ad-servers, trackers, malware, fake download links, cookie-consent banners, popups, modals, push notifications, survey, newsletter and subscribe popups, sharing, Google Chromecast, popup chats, post widgets, like widgets, comments, service workers, news widgets, JavaScript and CSS maps, PWA install banners, Webmanifests, SWF objects
! Version: 3.0.3340
! Last modified: 2024-07-15T02:07:07.895+02:00
! Expires: 24 hours (update frequency)
! Homepage: https://github.com/the-advoid/ad-void
! Entries: 6615
! Author: Igor Dimitrijeviฤ (@igorskyflyer)
! GitHub issues: https://github.com/the-advoid/ad-void/issues
! GitHub pull requests: https://github.com/the-advoid/ad-void/pulls
! License: https://github.com/the-advoid/ad-void/blob/main/LICENSE
! Maintained by: Aria, igorskyflyer and all of the contributors
! See the CONTRIBUTORS.md (https://github.com/the-advoid/ad-void/blob/main/CONTRIBUTORS.md) file for more information
! Source: World Wide Web
*/
```
`./filter.txt`
```adblock
[Adblock Plus 2.0]
!
! ___ __ _ __ _ __
! / | ____/ / | | / /____ (_)____/ /
! / /| | / __ / | | / // __ \ / // __ /
! / ___ |/ /_/ / | |/ // /_/ // // /_/ /
! /_/ |_|\____/ |___/ \____//_/ \____/
!
!
! {@!}
! Title: AdVoid.Full
! Description: Blocks major ad-servers, trackers, malware, fake download links, cookie-consent banners, popups, modals, push notifications, survey, newsletter and subscribe popups, sharing, Google Chromecast, popup chats, post widgets, like widgets, comments, service workers, news widgets, JavaScript and CSS maps, PWA install banners, Webmanifests, SWF objects
! Version: 3.0.3340
! Last modified: 2024-07-15T02:07:07.895+02:00
! Expires: 24 hours (update frequency)
! Homepage: https://github.com/the-advoid/ad-void
! Entries: 6615
! Author: Igor Dimitrijeviฤ (@igorskyflyer)
! GitHub issues: https://github.com/the-advoid/ad-void/issues
! GitHub pull requests: https://github.com/the-advoid/ad-void/pulls
! License: https://github.com/the-advoid/ad-void/blob/main/LICENSE
! Maintained by: Aria, igorskyflyer and all of the contributors
! See the CONTRIBUTORS.md (https://github.com/the-advoid/ad-void/blob/main/CONTRIBUTORS.md) file for more information
! Source: World Wide Web! {@0} Domains (global)
||02cscosgbuzl.top^
||05e11c9f6f.com^
||0af2a962b0102942d9a7df351b20be55.com^
```---
## ๐ Changelog
> โจ Changelog is available here: [CHANGELOG.md](https://github.com/igorskyflyer/npm-adblock-header-extract/blob/main/CHANGELOG.md).
---
## ๐ชช License
Licensed under the MIT license which is available here, [MIT license](https://github.com/igorskyflyer/npm-adblock-header-extract/blob/main/LICENSE).
---
## ๐งฌ Related
[@igor.dvlpr/aria](https://www.npmjs.com/package/@igor.dvlpr/aria)
> _๐งฌ Meet Aria, an efficient Adblock filter list compiler, with many features that make your maintenance of Adblock filter lists a breeze! ๐ฆ_
[@igor.dvlpr/strip-headings](https://www.npmjs.com/package/@igor.dvlpr/strip-headings)
> _โธ Strips Markdown headings!๐น_
[@igor.dvlpr/adblock-filter-counter](https://www.npmjs.com/package/@igor.dvlpr/adblock-filter-counter)
> _๐ฒ A dead simple npm module that counts Adblock filter rules.๐ฆ_
[@igor.dvlpr/jmap](https://www.npmjs.com/package/@igor.dvlpr/jmap)
> _๐ถ๏ธ Reads a JSON file into a Map. ๐ป_
[@igor.dvlpr/strip-html-headings](https://www.npmjs.com/package/@igor.dvlpr/strip-html-headings)
> _๐ Strips HTML headings! ๐ค_
---
Provided by **Igor Dimitrijeviฤ** ([*@igorskyflyer*](https://github.com/igorskyflyer/)).