-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support cosmetic filterlists #466
Merged
Merged
Changes from all commits
Commits
Show all changes
85 commits
Select commit
Hold shift + click to select a range
73b7274
easylist experiment
muodov 4063d9a
update easylist
muodov 781b60c
Tweak easylist hack
muodov 7440877
delay easylist detection
muodov 6268d6f
increase the easylist timeout
muodov 55f4cb7
Merge branch 'main' into cosmetic-easylist
muodov 7016c1b
update easylist
muodov 323cafc
Use fanboy-cookiemonster in the test extension
muodov a27664a
Initialize and apply cosmetic filters together with prehide rules
muodov e86edf4
Fall back to filterist when no pop-up is found
muodov 4ee88f3
Remove easylist rule
muodov 73d42ab
WIP
muodov 08844a2
WIP: add perf metrics
muodov 4a17530
add performance metrics
muodov 709c3a8
Allow disabling autoconsent per site (in the test extension)
muodov d3c171e
Use uBO version of easylist cookie
muodov 1e908bb
remove the perf metrics code
muodov e161c12
Use constructed stylesheets for cosmetic styles
muodov 0f48f16
minify the extension content script
muodov 559fe91
filterlist experiment
muodov 4b92532
Merge remote-tracking branch 'origin/main' into filterlist-experiment
muodov 28c308d
Add filterlist overrides
muodov 6e502a3
Update bundled filterlist
muodov ea1dbe9
minor filterlist changes
muodov 2362fe5
Logging tweaks
muodov e13c166
Tweak logs
muodov 9389cc3
Add a rule for wise.com
muodov cb21548
add a rule for nike
muodov c1131cc
Add a rule for dan.com
muodov 07501cf
Remove generic-cosmetic rule (too many false positives)
muodov c6f6d47
add rule for medium.com
muodov 26934b0
Add a rule for abc.net.au
muodov 4d7446b
Lint fix
muodov 1f31386
removed unused file
muodov e2d8569
support mobile aliexpress
muodov 5f174b3
Update rule for temu
muodov 1eccaed
Add rule for american airlines
muodov f867092
Add rule for tesla
muodov 377f777
Wrap filterlist code in try catch
muodov 497974f
Add a rule for admiral GDPR popups
muodov 1e6f72c
Tweak ensighten rule for britishairways.com
muodov 1a6383b
Merge branch 'wise' into filterlist-experiment
muodov dd13b60
Merge branch 'nike' into filterlist-experiment
muodov 5623bea
Merge branch 'dan-com' into filterlist-experiment
muodov 005a47d
Merge branch 'medium' into filterlist-experiment
muodov 1f9d022
Merge branch 'abc' into filterlist-experiment
muodov 3eb50dc
Merge branch 'aliexpress' into filterlist-experiment
muodov 1de2641
Merge branch 'aa' into filterlist-experiment
muodov 1196ae1
Merge branch 'tesla' into filterlist-experiment
muodov 2c51cef
Merge branch 'admiral' into filterlist-experiment
muodov 01d56d3
Merge branch 'ens-tweak' into filterlist-experiment
muodov b01adf2
Address minor PR comments
muodov 42daae1
comment overrides
muodov 3806f50
Merge branch 'filterlist-experiment' into filterlist-with-fixes
muodov 1bfe229
Merge branch 'main' into cosmetic-easylist
muodov feb2c02
Merge some parts of 'filterlist-with-fixes' into cosmetic-easylist
muodov 4ebdb92
update the adblocker library and use the provided style override
muodov cd92df9
Bundle filterlist in JS
muodov 6c0f6c8
Update filterlist on every release
muodov ddc1da0
Tweak watch command
muodov d80a1f5
Remove outdated comments
muodov 5da316a
Disable filterlist by default
muodov 3729136
Move log to a more appropriate place
muodov c560b38
remove unused ignore
muodov d2b77b6
Merge remote-tracking branch 'origin/main' into cosmetic-easylist
muodov a4b0db8
Lint fix in auto-generated file
muodov a49e906
Merge remote-tracking branch 'origin/main' into cosmetic-easylist
muodov 2f71b9d
Update filterlist
muodov 3d25afd
Remove autogenerated filterlist from git index
muodov cb7bf56
Do not commit changes to filterlist
muodov 5a9db3b
Update the build scripts to update filterlist when necessary
muodov 7c252ae
Regenerate package-lock (see https://github.com/npm/cli/issues/4828)
muodov 5140329
remove performance marks
muodov 53ae421
Produce separate builds with and without filterlist
muodov ce6cc1a
Avoid generating filterlist twice in ci
muodov e24840a
Export json rules
muodov b16d952
Do not commit filterlist file during release
muodov 4adf868
Build filterlist from easylist source
muodov 70e141a
Update readme
muodov bb93e6b
add link to DDG download page
muodov 05141c4
Merge branch 'main' into cosmetic-easylist
muodov 564ade7
cliqz/adblocker is renamed to ghostery/adblocker
muodov 0cf0332
Address minor PR comments
muodov 12e735f
Track the resulting filterlist in git
muodov 4ef5ed3
Add a ci job to update EasyList
muodov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Update filterlist | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
schedule: | ||
- cron: '0 3 * * SUN' # run every Sunday at 3:00 | ||
|
||
jobs: | ||
update_filterlist: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Use Node.js 18.x | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Update EasyList | ||
run: | | ||
npm run update-easylist | ||
|
||
- name: Read EasyList revision | ||
id: read-revision | ||
run: echo "revision=`cat rules/filterlists/easylist_revision.txt`"" >> "$GITHUB_OUTPUT" | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v7 | ||
with: | ||
title: Update filterlist to ${{ steps.read-revision.outputs.revision }} | ||
commit-message: Update filterlist to ${{ steps.read-revision.outputs.revision }} | ||
labels: | | ||
minor | ||
dependencies | ||
reviewers: muodov,sammacbeth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,5 @@ addon/*.js | |
.vscode/ | ||
.env | ||
.DS_Store | ||
rules/filterlists/easylist_*.txt | ||
lib/filterlist-engine.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { FiltersEngine } from '@ghostery/adblocker'; | ||
import { extractFeaturesFromDOM } from '@ghostery/adblocker-content'; | ||
import { parse as tldtsParse } from 'tldts-experimental'; | ||
import { getHidingStyle } from './utils'; | ||
|
||
export function deserializeFilterList(serializedEngine: Uint8Array) { | ||
return FiltersEngine.deserialize(serializedEngine) | ||
} | ||
|
||
export function getCosmeticStylesheet(engine: FiltersEngine): string { | ||
try { | ||
const parsed = tldtsParse(location.href); | ||
const hostname = parsed.hostname || ''; | ||
const domain = parsed.domain || ''; | ||
|
||
const cosmetics = engine.getCosmeticsFilters({ | ||
url: location.href, | ||
hostname, | ||
domain, | ||
|
||
// this extracts current ids, classes and attributes (depends on the current DOM state) | ||
...extractFeaturesFromDOM([document.documentElement]), | ||
|
||
getBaseRules: true, | ||
getInjectionRules: false, // we don't inject scripts atm | ||
getExtendedRules: true, | ||
getRulesFromDOM: true, | ||
getRulesFromHostname: true, | ||
|
||
hidingStyle: getHidingStyle('opacity'), | ||
}); | ||
return cosmetics.styles; | ||
} catch (e) { | ||
console.error('Error getting cosmetic rules', e); | ||
return ''; | ||
} | ||
} | ||
|
||
export function getFilterlistSelectors(styles: string): string { | ||
if (styles) { | ||
const selectorsOnly = styles.replace(/\s*{[^\\}]*}\s*/g, ',').replace(/,$/, ''); | ||
return selectorsOnly; | ||
} | ||
return ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
filterlist should be explicitly enabled by the browser