diff options
author | Florian Bruhin <me@the-compiler.org> | 2019-12-19 20:10:49 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2019-12-20 16:53:17 +0100 |
commit | b20eba35e91735ca954af72f5d5ae7d407b7bbf2 (patch) | |
tree | 53dab3b6fd34926b80ab83c7faac224f915b7991 | |
parent | c4b67473042589ff11e386f964d355b6212ee9d3 (diff) | |
download | qutebrowser-b20eba35e91735ca954af72f5d5ae7d407b7bbf2.tar.gz qutebrowser-b20eba35e91735ca954af72f5d5ae7d407b7bbf2.zip |
Add site specific quirks
WhatsApp Web:
See #4445
Google Accounts:
See #5147
Slack:
See #4669 (With older QtWebEngine versions, Slack refuses to work, despite
it (seemingly) working fine.)
Dell Support
Google Docs:
See #4805 and https://bugreports.qt.io/browse/QTBUG-69652
Note that the default UA with Chrome/... shows a "browser not supported"
warning.
Fixes #4810
-rw-r--r-- | doc/changelog.asciidoc | 9 | ||||
-rw-r--r-- | doc/help/settings.asciidoc | 10 | ||||
-rw-r--r-- | qutebrowser/browser/webengine/webenginesettings.py | 40 | ||||
-rw-r--r-- | qutebrowser/browser/webkit/webkitsettings.py | 2 | ||||
-rw-r--r-- | qutebrowser/config/configdata.yml | 9 |
5 files changed, 69 insertions, 1 deletions
diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index 573cb5018..c9e5ccc3c 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -28,6 +28,9 @@ Added - `fonts.contextmenu` - `colors.contextmenu.bg` - `colors.contextmenu.fg` +- New `content.site_specific_quirks` setting which enables workarounds for + websites with broken user agent parsing (enabled by default, see the "Fixed" + section for fixed websites). Changed ~~~~~~~ @@ -94,6 +97,12 @@ Fixed - `url.open_base_url = True` together with `url.auto_search = 'never'` is now handled correctly. - Fixed crash when a search engine URL turns out to be invalid. +- Site specific quirks which work around some broken websites: + - WhatsApp Web + - Google Accounts + - Slack (with older QtWebEngine versions) + - Dell.com support pages (with Qt 5.7) + - Google Docs (fixes broken IME/compose key) v1.8.3 (2019-12-05) ------------------- diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 35fae2b53..d48706ac9 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -168,6 +168,7 @@ |<<content.proxy,content.proxy>>|Proxy to use. |<<content.proxy_dns_requests,content.proxy_dns_requests>>|Send DNS requests over the configured proxy. |<<content.register_protocol_handler,content.register_protocol_handler>>|Allow websites to register protocol handlers via `navigator.registerProtocolHandler`. +|<<content.site_specific_quirks,content.site_specific_quirks>>|Enable quirks (such as faked user agent headers) needed to get specific sites to work properly. |<<content.ssl_strict,content.ssl_strict>>|Validate SSL handshakes. |<<content.user_stylesheets,content.user_stylesheets>>|List of user stylesheet filenames to use. |<<content.webgl,content.webgl>>|Enable WebGL. @@ -2222,6 +2223,15 @@ On QtWebEngine, this setting requires Qt 5.11 or newer. On QtWebKit, this setting is unavailable. +[[content.site_specific_quirks]] +=== content.site_specific_quirks +Enable quirks (such as faked user agent headers) needed to get specific sites to work properly. +This setting requires a restart. + +Type: <<types,Bool>> + +Default: +pass:[true]+ + [[content.ssl_strict]] === content.ssl_strict Validate SSL handshakes. diff --git a/qutebrowser/browser/webengine/webenginesettings.py b/qutebrowser/browser/webengine/webenginesettings.py index 4a677539f..fcdbd7d7e 100644 --- a/qutebrowser/browser/webengine/webenginesettings.py +++ b/qutebrowser/browser/webengine/webenginesettings.py @@ -35,7 +35,8 @@ from PyQt5.QtWebEngineWidgets import (QWebEngineSettings, QWebEngineProfile, from qutebrowser.browser.webengine import spell, webenginequtescheme from qutebrowser.config import config, websettings from qutebrowser.config.websettings import AttributeInfo as Attr -from qutebrowser.utils import utils, standarddir, qtutils, message, log +from qutebrowser.utils import (utils, standarddir, qtutils, message, log, + urlmatch) # The default QWebEngineProfile default_profile = typing.cast(QWebEngineProfile, None) @@ -329,6 +330,41 @@ def _init_profiles(): private_profile.setter.init_profile() +def _init_site_specific_quirks(): + if not config.val.content.site_specific_quirks: + return + + # default_ua = ("Mozilla/5.0 ({os_info}) " + # "AppleWebKit/{webkit_version} (KHTML, like Gecko) " + # "{qt_key}/{qt_version} " + # "{upstream_browser_key}/{upstream_browser_version} " + # "Safari/{webkit_version}") + no_qtwe_ua = ("Mozilla/5.0 ({os_info}) " + "AppleWebKit/{webkit_version} (KHTML, like Gecko) " + "{upstream_browser_key}/{upstream_browser_version} " + "Safari/{webkit_version}") + firefox_ua = "Mozilla/5.0 ({os_info}; rv:71.0) Gecko/20100101 Firefox/71.0" + new_chrome_ua = ("Mozilla/5.0 ({os_info}) " + "AppleWebKit/537.36 (KHTML, like Gecko) " + "Chrome/99 " + "Safari/537.36") + + user_agents = { + 'https://web.whatsapp.com/': no_qtwe_ua, + 'https://accounts.google.com/ServiceLogin': firefox_ua, + 'https://*.slack.com/*': new_chrome_ua, + 'https://docs.google.com/*': firefox_ua, + } + + if not qtutils.version_check('5.9'): + user_agents['https://www.dell.com/support/*'] = new_chrome_ua + + for pattern, ua in user_agents.items(): + config.instance.set_obj('content.headers.user_agent', ua, + pattern=urlmatch.UrlPattern(pattern), + hide_userconfig=True) + + def init(args): """Initialize the global QWebSettings.""" if (args.enable_webengine_inspector and @@ -345,6 +381,8 @@ def init(args): global_settings = WebEngineSettings(_SettingsWrapper()) global_settings.init_settings() + _init_site_specific_quirks() + def shutdown(): pass diff --git a/qutebrowser/browser/webkit/webkitsettings.py b/qutebrowser/browser/webkit/webkitsettings.py index f5e55607d..74b8a49a8 100644 --- a/qutebrowser/browser/webkit/webkitsettings.py +++ b/qutebrowser/browser/webkit/webkitsettings.py @@ -82,6 +82,8 @@ class WebKitSettings(websettings.AbstractSettings): Attr(QWebSettings.PrintElementBackgrounds), 'content.xss_auditing': Attr(QWebSettings.XSSAuditingEnabled), + 'content.site_specific_quirks': + Attr(QWebSettings.SiteSpecificQuirksEnabled), 'input.spatial_navigation': Attr(QWebSettings.SpatialNavigationEnabled), diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index 8316835a8..2d8d37e47 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -395,6 +395,15 @@ content.frame_flattening: This will flatten all the frames to become one scrollable page. +content.site_specific_quirks: + default: true + restart: true + type: Bool + desc: 'Enable quirks (such as faked user agent headers) needed to get + specific sites to work properly.' + +# emacs: ' + content.geolocation: default: ask type: BoolAsk |