Hide adblocked iframes.
We now hide iframes which have been blocked completely instead of displaying an error page in there. Displaying the error page also did break back/forward, e.g. on reddit. Fixes #493.
This commit is contained in:
parent
9736224fa6
commit
d6e87a2672
@ -121,8 +121,17 @@ class BrowserPage(QWebPage):
|
|||||||
else:
|
else:
|
||||||
error_str = info.errorString
|
error_str = info.errorString
|
||||||
if error_str == networkmanager.HOSTBLOCK_ERROR_STRING:
|
if error_str == networkmanager.HOSTBLOCK_ERROR_STRING:
|
||||||
|
# We don't set error_occured in this case.
|
||||||
error_str = "Request blocked by host blocker."
|
error_str = "Request blocked by host blocker."
|
||||||
# we don't set error_occured in this case.
|
main_frame = info.frame.page().mainFrame()
|
||||||
|
if info.frame != main_frame:
|
||||||
|
# Content in an iframe -> Hide the frame so it doesn't use
|
||||||
|
# any space. We can't hide the frame's documentElement
|
||||||
|
# directly though.
|
||||||
|
for elem in main_frame.documentElement().findAll('iframe'):
|
||||||
|
if QUrl(elem.attribute('src')) == info.url:
|
||||||
|
elem.setAttribute('style', 'display: none')
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
self._ignore_load_started = True
|
self._ignore_load_started = True
|
||||||
self.error_occured = True
|
self.error_occured = True
|
||||||
|
Loading…
Reference in New Issue
Block a user