如何防止在打开特定链接时从 Ubuntu chrome 弹出 xdg-open 对话?

问题描述

我正在尝试使用桌面网络 whatsapp(chrome、ubuntu)加入一个 whatsapp 组.当我点击加入群组时,它会显示下面的对话.我想永远从 chrome 中删除这个对话.我可以在关闭 xdg-open 对话后再次点击加入群组来加入群组.

我尝试了

解决方案

此解决方案适用于 Google Chrome 84.0.4147.89,适用于特定类型的 xdg 链接.例如,如果有问题的链接是 whatsapp://someurl,您可以使用:

sudo mkdir -p/etc/opt/chrome/policies/managed/&&echo '{ "URLWhitelist": ["whatsapp://*"] }' |sudo tee/etc/opt/chrome/policies/managed/whitelist.json

I am trying to join a whatsapp group using desktop web whatsapp (chrome, ubuntu). When I click on Join Group, It shows dialogue below.I want to remove this dialogue forever from chrome. I can join the group by clicking again on join the group after dismissing the xdg-open dialogue.

I tried Reset chrome protocol_handler chrome with no luck.

I also tried to dismiss the dialogue using python selenium with no luck using below code.

               try:

                    WebDriverWait(browser, 3).until(EC.alert_is_present(),
                           'Timed out waiting for PA creation ' +
                           'confirmation popup to appear.')
                    #if it doe
                    alert = browser.switch_to.alert()
                    alert.accept()
                    print "alert accepted"
                except TimeoutException:
                    print "no alert"
                    pass

Is there a way to dismiss the dialogue using python selenium or using some configuration file changes in chrome installation ?

解决方案

This solution works on Google Chrome 84.0.4147.89, for specific types of xdg links. For example, if the link in question is whatsapp://someurl, you can use:

sudo mkdir -p /etc/opt/chrome/policies/managed/ && echo '{ "URLWhitelist": ["whatsapp://*"] }' |sudo tee /etc/opt/chrome/policies/managed/whitelist.json

相关文章