Skip to content

Commit

Permalink
filters must be reloaded after setting, or there's a chance they won'…
Browse files Browse the repository at this point in the history
…t be ready before Selenium navigates
  • Loading branch information
Oaphi committed Aug 26, 2024
1 parent 3859890 commit 4c507bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sedd/ubo/ubo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from ..config import SEDDConfig
from .utils import ubo_set_user_settings, \
ubo_set_advanced_settings, ubo_set_selected_filters, \
ubo_set_whitelist, ubo_set_dynamic_rules, ubo_set_user_filters
ubo_set_whitelist, ubo_set_dynamic_rules, ubo_set_user_filters, \
ubo_reload_all_filters


def init_ubo_settings(browser: Firefox, config: SEDDConfig, ubo_id: str) -> bool:
Expand All @@ -26,6 +27,8 @@ def init_ubo_settings(browser: Firefox, config: SEDDConfig, ubo_id: str) -> bool
ubo_set_whitelist(browser, settings)
ubo_set_dynamic_rules(browser, settings)
ubo_set_user_filters(browser, settings)

ubo_reload_all_filters(browser)
except:
print('Failed to set uBLock config, using defaults')
print(exc_info())
10 changes: 10 additions & 0 deletions sedd/ubo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,13 @@ def ubo_set_user_filters(browser: Firefox, settings: SEDDUboSettings) -> None:
content: toOverwrite.join('\\n')
})
""", settings['userFilters'])


def ubo_reload_all_filters(browser: Firefox) -> None:
browser.execute_async_script("""
const done = arguments[0]
globalThis.vAPI.messaging.send('dashboard', {
what: 'reloadAllFilters',
}).then(done)
""")

0 comments on commit 4c507bb

Please # to comment.