Allow Flash content in Chrome 71 running via chromedriver

后端 未结 2 1289
一生所求
一生所求 2020-12-09 00:11

I\'ve been using this to allow flash for chrome version 69.

ChromeOptions options = new ChromeOptions();
// disable ephemeral flash permissions flag
options.         


        
相关标签:
2条回答
  • 2020-12-09 00:59

    I haven't find any option yet, and I'm afraid won't find ever.

    The workaround for Windows is to use Group Policies (via adding entries to registry):

    reg add HKLM\Software\Policies\Google\Chrome /v DefaultPluginsSetting /d 1 /t REG_DWORD /f
    reg add HKLM\Software\Policies\Google\Chrome\PluginsAllowedForUrls /v 1 /d http://* /t REG_SZ /f
    reg add HKLM\Software\Policies\Google\Chrome\PluginsAllowedForUrls /v 2 /d https://* /t REG_SZ /f
    

    or just create file with .reg extension and put text below into it:

    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google]
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome]
    "DefaultPluginsSetting"=dword:00000001
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\PluginsAllowedForUrls]
    "1"="http://*"
    "2"="https://*"
    

    then save and double-click this file.

    0 讨论(0)
  • 2020-12-09 01:12

    My little workaround about this, ty to @doctordrue ;)

    from winreg import *
    import sys
    
    reg_path = 'Software\Policies\Google\Chrome\PluginsAllowedForUrls'
    
    allow_flash = {'1': 'https://url'}
    
    if sys.platform == 'win32':
        try:
            try:
                RegistryKey = OpenKey(HKEY_LOCAL_MACHINE, reg_path, 0, KEY_ALL_ACCESS)
                for K,V in allow_flash.items():
                    try:
                        if QueryValueEx(RegistryKey, K)[0] == V: pass
                        else:
                            SetValueEx(RegistryKey, K, 0, REG_SZ, V)
                    except FileNotFoundError:
                        SetValueEx(RegistryKey, K, 0, REG_SZ, V)
                CloseKey(RegistryKey)
            except FileNotFoundError:
                RegistryKey = CreateKey(HKEY_LOCAL_MACHINE, reg_path)
                for K, V in allow_flash.items():
                    SetValueEx(RegistryKey, K, 0, REG_SZ, V)
                CloseKey(RegistryKey)
        except:
            # write_in_log(traceback.format_exc())
            pass
    
    0 讨论(0)
提交回复
热议问题