Commit 16ca23a2 authored by Cédric Bellegarde's avatar Cédric Bellegarde

Fix an issue with twitter -> youtube loading

parent 1128512f
Pipeline #58310 passed with stage
in 8 minutes and 40 seconds
...@@ -165,7 +165,7 @@ ...@@ -165,7 +165,7 @@
<description /> <description />
</key> </key>
<key type="b" name="autoplay-videos"> <key type="b" name="autoplay-videos">
<default>false</default> <default>true</default>
<summary>Autoplay videos</summary> <summary>Autoplay videos</summary>
<description /> <description />
</key> </key>
......
...@@ -563,54 +563,29 @@ class WebView(WebKit2.WebView): ...@@ -563,54 +563,29 @@ class WebView(WebKit2.WebView):
@param navigation_action as WebKit2.NavigationAction @param navigation_action as WebKit2.NavigationAction
@param elapsed as float @param elapsed as float
""" """
def on_load_changed(webview, event): popup_block = App().settings.get_value("popupblock")
parsed = urlparse(webview.uri) parsed = urlparse(webview.uri)
# First, adblocking exception = elapsed < 1.0 or\
if not parsed.netloc: App().popup_exceptions.find_parsed(parsed)
return properties = webview.get_window_properties()
if App().settings.get_value("adblock") and\ if not exception and popup_block and\
parsed.scheme in ["http", "https"] and\ navigation_action.get_navigation_type() in [
not App().adblock_exceptions.find_parsed(parsed): WebKit2.NavigationType.OTHER,
if App().adblock.is_netloc_blocked(parsed.netloc) or\ WebKit2.NavigationType.RELOAD,
App().adblock.is_uri_blocked(webview.uri, WebKit2.NavigationType.BACK_FORWARD]:
parsed.netloc): related.add_popup(webview)
webview.destroy() webview.connect("close", self.__on_popup_close, related)
return if related == self._window.container.current.webview:
if event != WebKit2.LoadEvent.FINISHED: self._window.toolbar.title.show_indicator(
return Indicator.POPUPS)
else: elif (properties.get_toolbar_visible() or
webview.disconnect_by_func(on_load_changed) properties.get_scrollbars_visible()) and\
not self._window.modifiers == Gdk.KEY_Shift_L:
# Then popup blocking self._window.container.add_webview_with_new_view(
popup_block = App().settings.get_value("popupblock") webview,
if related.uri is not None: LoadingType.FOREGROUND)
parsed_related = urlparse(related.uri) else:
exception = elapsed < 1.0 or\ self._window.container.popup_webview(webview, True)
App().popup_exceptions.find_parsed(parsed_related)
else:
exception = False
properties = webview.get_window_properties()
if not exception and popup_block and\
navigation_action.get_navigation_type() in [
WebKit2.NavigationType.OTHER,
WebKit2.NavigationType.RELOAD,
WebKit2.NavigationType.BACK_FORWARD]:
related.add_popup(webview)
webview.connect("close", self.__on_popup_close, related)
if related == self._window.container.current.webview:
self._window.toolbar.title.show_indicator(
Indicator.POPUPS)
elif (properties.get_toolbar_visible() or
properties.get_scrollbars_visible()) and\
not self._window.modifiers == Gdk.KEY_Shift_L:
self._window.container.add_webview_with_new_view(
webview,
LoadingType.FOREGROUND)
else:
self._window.container.popup_webview(webview, True)
webview.connect("load-changed", on_load_changed)
def __on_popup_close(self, webview, related): def __on_popup_close(self, webview, related):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment