Skip to content

Commit

Permalink
Remove flickering for CSS filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Snuupy committed Aug 21, 2018
1 parent 63363a7 commit d192d23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/background/api/cosmeticFilterAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export const applySiteFilters = (hostname: string) => {
storeData.cosmeticFilterList[hostname].map((rule: string) => {
console.log('applying rule', rule)
chrome.tabs.insertCSS({
code: `${rule} {display: none;}`
code: `${rule} {display: none;}`,
runAt: 'document_start'
})
})
}
Expand Down
9 changes: 6 additions & 3 deletions test/app/background/api/cosmeticFilterAPITest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ describe('cosmeticFilterTestSuite', () => {
})
cosmeticFilterAPI.applySiteFilters('brave.com')
assert.deepEqual(this.insertCSSStub.getCall(0).args[0], {
code: `${filter} {display: none;}`
code: `${filter} {display: none;}`,
runAt: 'document_start'
})
})
it('applies multiple filters correctly', function () {
Expand All @@ -195,10 +196,12 @@ describe('cosmeticFilterTestSuite', () => {
})
cosmeticFilterAPI.applySiteFilters('brave.com')
assert.deepEqual(this.insertCSSStub.getCall(0).args[0], {
code: `${filter} {display: none;}`
code: `${filter} {display: none;}`,
runAt: 'document_start'
})
assert.deepEqual(this.insertCSSStub.getCall(1).args[0], {
code: `${filter2} {display: none;}`
code: `${filter2} {display: none;}`,
runAt: 'document_start'
})

})
Expand Down

0 comments on commit d192d23

Please sign in to comment.