Skip to content

Commit

Permalink
Export eval snippets (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
muodov authored Dec 16, 2024
1 parent 8cb64ee commit a766cea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { FiltersEngine } from '@ghostery/adblocker';
import serializedEngine from './filterlist-engine';
import { checkHeuristicPatterns } from './heuristics';

export { snippets as evalSnippets } from './eval-snippets';

function filterCMPs(rules: AutoCMP[], config: Config) {
return rules.filter((cmp) => {
return (
Expand Down Expand Up @@ -302,7 +304,7 @@ export default class AutoConsent {
this.detectHeuristics();
onFirstPopupAppears(cmp);
})
.catch(() => null);
.catch(() => {});

const results = await Promise.allSettled(tasks);
const popups: AutoCMP[] = [];
Expand Down
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ chrome.runtime.onMessage.addListener((message) => {
});
```

In some environments (e.g. browser extensions), it's useful to access [eval snippet functions](./lib/eval-snippets.ts) directly in the background script. This can be done by importing the `evalSnippets` object from the library:

```javascript
import { evalSnippets } from '@duckduckgo/autoconsent';
```

## Browser extension

Autoconsent comes with a reference extension implementation. It is not published in stores since the feature is available in all [DuckDuckGo apps](https://duckduckgo.com/app), but you can build it yourself and use for testing.
Expand Down

0 comments on commit a766cea

Please sign in to comment.