Disble Chrome notifications via Preferences file
* Instead of system-wide via the registry * Avoids the "Managed by your organization" message
This commit is contained in:
parent
7e2db4c1ee
commit
44cc931840
3 changed files with 28 additions and 6 deletions
|
|
@ -1,5 +1,8 @@
|
|||
# Wizard Kit: Functions - Browsers
|
||||
|
||||
import json
|
||||
import pathlib
|
||||
|
||||
from functions.common import *
|
||||
from operator import itemgetter
|
||||
from settings.browsers import *
|
||||
|
|
@ -161,6 +164,28 @@ def clean_mozilla_profile(profile):
|
|||
f.write('user_pref("{}", {});\n'.format(k, v))
|
||||
|
||||
|
||||
def disable_chrome_notifications():
|
||||
"""TODO"""
|
||||
for profile in browser_data.get('Google Chrome', {}).get('profiles', []):
|
||||
pref_file = pathlib.Path(f'{profile["user_data_path"]}/Preferences')
|
||||
if pref_file.exists():
|
||||
pref_data = None
|
||||
|
||||
# Read current preferences
|
||||
with open(pref_file, 'r') as f:
|
||||
pref_data = json.loads(f.read())
|
||||
|
||||
# Set notifications blocks
|
||||
defaults_key = 'default_content_setting_values'
|
||||
if defaults_key not in pref_data['profiles']:
|
||||
pref_data['profiles'][defaults_key] = {}
|
||||
pref_data['profiles'][defaults_key]['notifications'] = 2
|
||||
|
||||
# Write new preferences
|
||||
with open(pref_file, 'w') as f:
|
||||
f.write(json.dumps(pref_data, separators=(',', ':')))
|
||||
|
||||
|
||||
def get_browser_details(name):
|
||||
"""Get installation and profile details for all supported browsers."""
|
||||
browser = SUPPORTED_BROWSERS[name].copy()
|
||||
|
|
|
|||
|
|
@ -27,10 +27,6 @@ MOZILLA_FIREFOX_UBO_PATH = r'{}\{}\ublock_origin.xpi'.format(
|
|||
os.environ.get('PROGRAMFILES'),
|
||||
r'Mozilla Firefox\distribution\extensions')
|
||||
SETTINGS_GOOGLE_CHROME = {
|
||||
r'Software\Policies\Google\Chrome': {
|
||||
'DWORD Items': {'DefaultNotificationsSetting': 2},
|
||||
# 1: Allow, 2: Don't allow, 3: Ask
|
||||
},
|
||||
r'Software\Google\Chrome\Extensions\cjpalhdlnbpafiamejdnhcphjbkeiagm': {
|
||||
'SZ Items': {
|
||||
'update_url': 'https://clients2.google.com/service/update2/crx'},
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ SETUP_ACTIONS = OrderedDict({
|
|||
'Browser add-ons': {'New': True, 'Dat': True, 'Cur': True, 'HW': False, 'Verf': False, 'Function': install_adblock, 'Just run': True,
|
||||
'Pause': 'Please enable uBlock Origin for all browsers',
|
||||
},
|
||||
'Chrome Notifications': {'New': True, 'Dat': True, 'Cur': True, 'HW': False, 'Verf': False, 'Function': disable_chrome_notifications,},
|
||||
'Classic Start': {'New': True, 'Dat': True, 'Cur': True, 'HW': False, 'Verf': False, 'Function': config_classicstart, 'Win10 only': True,},
|
||||
'Config Windows Updates': {'New': True, 'Dat': True, 'Cur': True, 'HW': True, 'Verf': True, 'Function': config_windows_updates, 'Win10 only': True,},
|
||||
'Enable System Restore': {'New': True, 'Dat': True, 'Cur': True, 'HW': True, 'Verf': True, 'Function': enable_system_restore,},
|
||||
|
|
@ -126,7 +127,7 @@ SETUP_ACTIONS = OrderedDict({
|
|||
'Device Manager': {'New': True, 'Dat': True, 'Cur': True, 'HW': True, 'Verf': False, 'Function': open_device_manager, 'KWArgs': {'cs': 'STARTED'},},
|
||||
'HWiNFO sensors': {'New': True, 'Dat': True, 'Cur': True, 'HW': True, 'Verf': False, 'Function': run_hwinfo_sensors, 'KWArgs': {'cs': 'STARTED'},},
|
||||
'Snappy': {'New': True, 'Dat': True, 'Cur': True, 'HW': True, 'Verf': False, 'Function': open_snappy_driver_origin, 'KWArgs': {'cs': 'STARTED'},},
|
||||
'Speed test': {'New': True, 'Dat': True, 'Cur': True, 'HW': True, 'Verf': False, 'Function': open_speedtest, 'KWArgs': {'cs': 'STARTED'},},
|
||||
#'Speed test': {'New': True, 'Dat': True, 'Cur': True, 'HW': True, 'Verf': False, 'Function': open_speedtest, 'KWArgs': {'cs': 'STARTED'},},
|
||||
'Windows Updates': {'New': True, 'Dat': True, 'Cur': True, 'HW': False, 'Verf': False, 'Function': open_windows_updates, 'KWArgs': {'cs': 'STARTED'},},
|
||||
'Windows Activation': {'New': True, 'Dat': True, 'Cur': True, 'HW': False, 'Verf': False, 'Function': open_windows_activation, 'If not activated': True, 'KWArgs': {'cs': 'STARTED'},},
|
||||
'Sleep': {'New': True, 'Dat': True, 'Cur': True, 'HW': True, 'Verf': False, 'Function': sleep, 'Just run': True, 'KWArgs': {'seconds': 3},},
|
||||
|
|
@ -393,7 +394,7 @@ def main():
|
|||
pass
|
||||
|
||||
# Verf step
|
||||
if ask('Open programs (Activation, Device Manager, etc...)? '):
|
||||
if setup_mode == 'Verf' and ask('Open programs (Activation, Device Manager, etc...)? '):
|
||||
open_all_the_things()
|
||||
|
||||
# Done
|
||||
|
|
|
|||
Loading…
Reference in a new issue