EnableTrackingProtection_options = 1 #edit here
"""
give 0 in the EnableTrackingProtection_options if you want to disable the Enhanced Tracking Protection
give 1 in the EnableTrackingProtection_options if you want to enable the Enhanced Tracking Protection
"""

Https_Only_Mode_options = 1 #edit here
"""
give 0 in the Https_Only_Mode_options if you want to disable the HTTPS-Only Mode
give 1 in the Https_Only_Mode_options if you want to enable the HTTPS-Only Mode
"""

SafeBrowsing_options = 1 #edit here
"""
give 0 in SafeBrowsing_options if you want the following things to be disabled,
    |*| Block dangerous and deceptive content
    |*| Block dangerous downloads
    |*| Warn you about unwanted and uncommon software

give 1 in SafeBrowsing_options if you want the following things to be enabled,
    |*| Block dangerous and deceptive content
    |*| Block dangerous downloads
    |*| Warn you about unwanted and uncommon software
"""

PrivateBrowsing_options = 1 #edit here
"""
Use the value 0 in PrivateBrowsing_options if you want to enable private browsing
Use the value 1 in PrivateBrowsing_options if you want to disable private browsing
"""

import os
from subprocess import PIPE, Popen
import ctypes

class disable_file_system_redirection:
    _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
    _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
    def __enter__(self):
        self.old_value = ctypes.c_long()
        self.success = self._disable(ctypes.byref(self.old_value))
    def __exit__(self, type, value, traceback):
        if self.success:
            self._revert(self.old_value)
            
def ecmd(command):   
    from subprocess import Popen, PIPE
    import ctypes
    
    with disable_file_system_redirection():
        obj = Popen(command, shell = True, stdout = PIPE, stderr = PIPE)
    out, err = obj.communicate()
    ret=obj.returncode
    if ret==0:
        if out:
            return out.strip()
        else:
            return ret
    else:
        if err:
            return err.strip()
        else:
            return ret
            
print(ecmd('REG ADD HKLM\Software\Policies\Mozilla\Firefox\EnableTrackingProtection /v Value /t REG_DWORD /d %s /f'%(EnableTrackingProtection_options)))
print(ecmd('REG ADD HKLM\Software\Policies\Mozilla\Firefox\Preferences /v dom.security.https_only_mode /t REG_DWORD /d %s /f'%(Https_Only_Mode_options)))
print(ecmd('REG ADD HKLM\Software\Policies\Mozilla\Firefox\Preferences /v browser.safebrowsing.phishing.enabled /t REG_DWORD /d %s /f'%(SafeBrowsing_options)))
print(ecmd('REG ADD HKLM\Software\Policies\Mozilla\Firefox\Preferences /v browser.safebrowsing.malware.enabled /t REG_DWORD /d %s /f'%(SafeBrowsing_options)))
print(ecmd('REG ADD HKLM\Software\Policies\Mozilla\Firefox\Preferences /v browser.safebrowsing.downloads.enabled /t REG_DWORD /d %s /f'%(SafeBrowsing_options)))
print(ecmd('REG ADD HKLM\Software\Policies\Mozilla\Firefox\Preferences /v browser.safebrowsing.downloads.remote.block_uncommon /t REG_DWORD /d %s /f'%(SafeBrowsing_options)))
print(ecmd('REG ADD HKLM\Software\Policies\Mozilla\Firefox\Preferences /v browser.safebrowsing.downloads.remote.block_potentially_unwanted /t REG_DWORD /d %s /f'%(SafeBrowsing_options)))
print(ecmd('REG ADD HKLM\Software\Policies\Mozilla\Firefox /v DisablePrivateBrowsing /t REG_DWORD /d %s /f'%(PrivateBrowsing_options)))