From ceba2e5ff239ace2b08ad01ee5711245b784cf6f Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 18 Aug 2018 17:53:50 -0700 Subject: [PATCH] Add d7/Firefox workaround * When Firefox is run from d7ii all tabs crash thus preventing installing uBO * Added d7_forefix_fix.py to install uBO just for mozilla-type browsers --- .bin/Scripts/d7_firefox_fix.py | 44 ++++++++++++++++++++++++++++++ .bin/Scripts/functions/browsers.py | 10 +++++-- 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 .bin/Scripts/d7_firefox_fix.py diff --git a/.bin/Scripts/d7_firefox_fix.py b/.bin/Scripts/d7_firefox_fix.py new file mode 100644 index 00000000..27b33112 --- /dev/null +++ b/.bin/Scripts/d7_firefox_fix.py @@ -0,0 +1,44 @@ +# Wizard Kit: Install uBlock Origin for Firefox + +import os +import sys + +# Init +os.chdir(os.path.dirname(os.path.realpath(__file__))) +sys.path.append(os.getcwd()) +from functions.browsers import * +from functions.cleanup import * +from functions.setup import * +init_global_vars() +os.system('title {}: User Checklist Tool'.format(KIT_NAME_FULL)) +global_vars['LogFile'] = r'{LogDir}\User Checklist ({USERNAME}).log'.format( + **global_vars, **global_vars['Env']) +D7_MODE = 'd7mode' in sys.argv + +if __name__ == '__main__': + try: + stay_awake() + clear_screen() + print_info('{}: Firefox Fix for d7') + other_results = { + 'Warning': { + 'NotInstalledError': 'Not installed', + 'NoProfilesError': 'No profiles found', + }} + + # Scan for Firefox browsers + print_info('Scanning for Firefox browsers') + scan_for_browsers(just_firefox=True) + + # Install uBlock Origin + print_info('Installing uBlock Origin') + install_adblock(just_firefox=True) + + # Done + print_standard('\nDone.') + pause('Press Enter to exit...') + exit_script() + except SystemExit: + pass + except: + major_exception() diff --git a/.bin/Scripts/functions/browsers.py b/.bin/Scripts/functions/browsers.py index 485a4ef5..50d0a990 100644 --- a/.bin/Scripts/functions/browsers.py +++ b/.bin/Scripts/functions/browsers.py @@ -374,9 +374,11 @@ def get_mozilla_profiles(search_path, dev=False): return profiles -def install_adblock(indent=8, width=32): +def install_adblock(indent=8, width=32, just_firefox=False): """Install adblock for all supported browsers.""" for browser in sorted(browser_data): + if just_firefox and browser_data[browser]['base'] != 'mozilla': + continue exe_path = browser_data[browser].get('exe_path', None) function=run_program if not exe_path: @@ -483,9 +485,11 @@ def reset_browsers(indent=8, width=32): indent=indent, width=width, function=function, other_results=other_results, profile=profile) -def scan_for_browsers(): +def scan_for_browsers(just_firefox=False): """Scan system for any supported browsers.""" - for name in sorted(SUPPORTED_BROWSERS): + for name, details in sorted(SUPPORTED_BROWSERS.items()): + if just_firefox and details['base'] != 'mozilla': + continue try_and_print(message='{}...'.format(name), function=get_browser_details, cs='Detected', other_results=other_results, name=name)