https://github.com/silverwind/fetch-css
Extract CSS from websites and browser extensions
https://github.com/silverwind/fetch-css
Last synced: about 1 year ago
JSON representation
Extract CSS from websites and browser extensions
- Host: GitHub
- URL: https://github.com/silverwind/fetch-css
- Owner: silverwind
- License: bsd-2-clause
- Created: 2020-02-22T18:08:21.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-05T02:01:24.000Z (about 2 years ago)
- Last Synced: 2025-04-20T00:38:19.677Z (about 1 year ago)
- Language: JavaScript
- Size: 590 KB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fetch-css
[](https://www.npmjs.org/package/fetch-css) [](https://www.npmjs.org/package/fetch-css)
> Extract CSS from websites and browser extensions
## Usage
```console
npm i fetch-css
```
```js
import fetchCss from "fetch-css";
// retrieve CSS of a website
const [{css}] = await fetchCss([{url: "https://example.com"}]);
// extract CSS from a Chrome extension
const [{css}] = await fetchCss([{crx: "hlepfoohegkhhmjieoechaddaejaokhf"}]);
```
## API
### `fetchCss(sources)`
- `sources`: *Array* Array of source objects
- `source`: *Object*
- `url`: *string* or *Array* An absolute URL pointing to either a website or directly to a CSS or JS file (to extract inlined CSS strings from)
- `fetchOpts`: *Object* Options passed to [fetch](https://github.com/npm/make-fetch-happen#fetch)
- `crx`: *string* A Chrome extension id
- `contentScriptsOnly`: *boolean* Whether to pull only content scripts from a extension. Default: `false`
- `strict`: *boolean* Whether to throw an error if fetch fails. Default: `false`
Returns a `Promise` that resolves to a `sources` array with additional `css` properties present on each source.
## Related
- [remap-css](https://github.com/silverwind/remap-css) - Remap CSS rules based on declaration value
© [silverwind](https://github.com/silverwind), distributed under BSD licence