Skip to content

Commit fcf6653

Browse files
committed
prevent opening links in browser if not clicked by user
1 parent aff6074 commit fcf6653

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

devdocs_desktop.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,13 +428,12 @@ def on_webview_decide_policy(self, _widget, decision, dtype):
428428
if dtype == WebKit2.PolicyDecisionType.NAVIGATION_ACTION:
429429
nav = decision.get_navigation_action()
430430
uri = nav.get_request().get_uri()
431-
usr = self.open_link or nav.is_user_gesture()
432431

433-
self.open_link = False
434-
435-
if usr and not uri.startswith(self.app_url):
436-
decision.ignore()
432+
if self.open_link and not uri.startswith(self.app_url):
437433
webbrowser.open(uri)
434+
decision.ignore()
435+
436+
self.open_link = False
438437

439438
def on_webview_title_changed(self, _widget, _title):
440439
title = self.webview.get_title().replace(' — DevDocs', '')

0 commit comments

Comments
 (0)