Finish Chrome v2 loading

This commit is contained in:
Timothyxxx
2024-01-24 23:05:28 +08:00
parent acfb232cba
commit 5dea912d01
8 changed files with 408 additions and 13 deletions

View File

@@ -95,3 +95,45 @@ def is_shortcut_on_desktop(shortcuts: Dict[str, str], rule):
raise TypeError(f"{rule['type']} not support yet!")
else:
raise TypeError(f"{rule['type']} not support yet!")
def check_history_deleted(history_data, rule):
"""
Check if the history is deleted.
"""
if rule['type'] == 'keywords':
history_domains = [history[0] for history in history_data]
for keyword in rule['keywords']:
for history_domain in history_domains:
if keyword in history_domain:
return 0.
return 1.
else:
raise TypeError(f"{rule['type']} not support yet!")
def check_enabled_experiments(enabled_experiments, rule):
"""
Check if the enabled experiments are as expected.
"""
enabled_experiments_names = [experiment.split("@")[0] for experiment in enabled_experiments]
if rule['type'] == 'names':
return 1. if enabled_experiments_names == rule['names'] else 0.
else:
raise TypeError(f"{rule['type']} not support yet!")
def check_font_size(font_size, rule):
"""
Check if the font size is as expected.
"""
default_font_size = font_size['default_font_size']
if rule['type'] == 'value':
return 1. if default_font_size == rule['value'] else 0.
elif rule['type'] == 'range':
return 1. if rule['min'] < default_font_size < rule['max'] else 0.
else:
raise TypeError(f"{rule['type']} not support yet!")