{"action":"created","issue":{"url":"https://api.github.com/repos/qutebrowser/qutebrowser/issues/3636","repository_url":"https://api.github.com/repos/qutebrowser/qutebrowser","labels_url":"https://api.github.com/repos/qutebrowser/qutebrowser/issues/3636/labels{/name}","comments_url":"https://api.github.com/repos/qutebrowser/qutebrowser/issues/3636/comments","events_url":"https://api.github.com/repos/qutebrowser/qutebrowser/issues/3636/events","html_url":"https://github.com/qutebrowser/qutebrowser/issues/3636","id":300052467,"number":3636,"title":"Support more per-domain settings","user":{"login":"The-Compiler","id":625793,"avatar_url":"https://avatars0.githubusercontent.com/u/625793?v=4","gravatar_id":"","url":"https://api.github.com/users/The-Compiler","html_url":"https://github.com/The-Compiler","followers_url":"https://api.github.com/users/The-Compiler/followers","following_url":"https://api.github.com/users/The-Compiler/following{/other_user}","gists_url":"https://api.github.com/users/The-Compiler/gists{/gist_id}","starred_url":"https://api.github.com/users/The-Compiler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/The-Compiler/subscriptions","organizations_url":"https://api.github.com/users/The-Compiler/orgs","repos_url":"https://api.github.com/users/The-Compiler/repos","events_url":"https://api.github.com/users/The-Compiler/events{/privacy}","received_events_url":"https://api.github.com/users/The-Compiler/received_events","type":"User","site_admin":false},"labels":[{"id":157566448,"url":"https://api.github.com/repos/qutebrowser/qutebrowser/labels/component:%20config","name":"component: config","color":"0052cc","default":false},{"id":267497012,"url":"https://api.github.com/repos/qutebrowser/qutebrowser/labels/priority:%201%20-%20middle","name":"priority: 1 - middle","color":"0e8a16","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-02-25T19:14:57Z","updated_at":"2018-03-26T22:27:53Z","closed_at":null,"author_association":"COLLABORATOR","body":"Split off from #27 - settings which would be useful per-domain:\r\n\r\n---\r\n\r\nSome more musings about what code this is going to affect how, what's possible to set, and what kind of URLs should be affected, prompted by this IRC conversation:\r\n\r\n```\r\n2017-10-10 16:29:18     jkamat  also, re: domain matching. If I style 'a.com' and it has an iframe or external resources linking to b.com, will those get the per-domain settings of a.com (since that's the original page)\r\n2017-10-10 16:31:22     hola1_  no\r\n2017-10-10 16:31:28     hola1_  cause it's not the same domain\r\n2017-10-10 16:33:21     jkamat  that could be annoying, imo. I guess it's possible to go through and add rules for the iframe domains as well...\r\n2017-10-10 16:42:21     hola1_  that's the intension behind per-_domain_ settings... every domain which is called, get's it's own settings no matter if in an iframe or as page (except it's done like in uMatrix where in a.com containing b.com, b.com can have other settings for b.com than c.com containing b.com)\r\n2017-10-10 16:44:10     jkamat  I think that from a high level (ignoring requests and all) per-domain settings make it possible to \"go to something.com\" and have \"settings apply on that website\", which wouldn't be the case if something.com was implemented with a ton of iframes or similar\r\n2017-10-10 16:51:45     The-Compiler    jkamat: so many unsolved questions...\r\n2017-10-10 16:52:12     The-Compiler    but yeah, I also tend to think that it wouldn't affect frames from a different origin\r\n2017-10-10 16:53:19     The-Compiler    let's say you have stylesheets for blog.example.com, and that has an iframe from youtube.com or whatever - I don't think the styling rules for blog.example.com should be applied to YouTube\r\n2017-10-10 16:56:25     gilbertw1       I agree with that, iframes generally should be treated as a completely separate entity (which they are)\r\n2017-10-10 17:05:29     jkamat  hmm, I guess that's true. I'm more worried about externally hosted javascript as well (suppose a script linked from a different domain exists, it won't run on a site with javascript disabled, right?)\r\n2017-10-10 17:09:08     gilbertw1       You mean that if you block all javascript on any pages from Domain X using per-domain settings, you don't want it loading and running scripts from Domain Y when you access a page on Domain X\r\n2017-10-10 17:09:39     jkamat  yes, that's a clearer explanation of what I want :P\r\n2017-10-10 17:11:07     gilbertw1       Hah, that's a good point that I don't know the answer to. It's definitely a valid use case I'd assume many would want\r\n2017-10-10 17:13:08     hola1_  if i understand you right, you explaining the same what i've tryed and what uMatrix ( https://github.com/gorhill/uMatrix ) does\r\n```\r\n\r\nWe basically have three kind of URLs:\r\n\r\n- The current page qutebrowser is on. I'm calling this *\"top-level URL\"* here.\r\n- The URL a resource is loaded from. I'm calling this *\"resource URL\"* here.\r\n- The URL of a frame/iframe. I'm calling this *\"frame URL\"* here.\r\n\r\n# User stylesheets\r\n\r\n- Use case: Applying per-domain stylesheets from e.g. [solarized everything](https://github.com/alphapapa/solarized-everything-css).\r\n\r\n## QtWebKit\r\n\r\nWe can use [QWebSettings::setUserStyleSheetUrl](http://doc.qt.io/archives/qt-5.5/qwebsettings.html#setUserStyleSheetUrl) based on the top-level URL.\r\n\r\n## QtWebEngine\r\n\r\nSince we use JavaScript to apply the stylesheet, it's probably easy to get the frame URL, and I think it's better to use that for the stylesheet. In other words, if you're on www.example.com and that has an iframe for www.youtube.com, the stylesheet for example.com doesn't apply in the YouTube frame.\r\n\r\nWe could also format the top-level URL into JavaScript from Python (or get it in JS directly? Probably not?) - but I think we don't need it at all.\r\n\r\n# Cookies\r\n\r\n- Use case: Accepting cookies selectively\r\n\r\n## QtWebKit\r\n\r\nIn [QNetworkCookieJar::insertCookie](http://doc.qt.io/qt-5/qnetworkcookiejar.html#insertCookie) we should be able get the resource URL (?) via [QNetworkCookie::domain](http://doc.qt.io/qt-5/qnetworkcookie.html#domain). I'm not sure whether we can get the top-level URL in any way...\r\n\r\n## QtWebEngine\r\n\r\nThere's no cookie filter API yet ([WIP Qt 5.11 change](https://codereview.qt-project.org/#/c/204302/)). We could probably watch [QWebEngineCookieStore::cookieAdded](http://doc.qt.io/qt-5/qwebenginecookiestore.html#cookieAdded) and call [deleteCookie](http://doc.qt.io/qt-5/qwebenginecookiestore.html#deleteCookie) right away.\r\n\r\nLooks like there's no way to get the top-level URL here either?\r\n\r\n# User agent\r\n\r\n- Use case: Workarounds for sites relying on UA checking\r\n\r\n## QtWebKit\r\n\r\nOverride [QWebEnginePage::userAgentForUrl](http://doc.qt.io/archives/qt-5.5/qwebpage.html#userAgentForUrl). We can probably get both the top-level URL (from the page) and the request URL.\r\n\r\n## QtWebEngine\r\n\r\nWe have the user agent set via [QWebEngineProfile::setHttpUserAgent](http://doc.qt.io/qt-5/qwebengineprofile.html#setHttpUserAgent) and that's global. However, at least for headers (but not `window.navigator.userAgent`) we can use [QWebEngineUrlRequestInterceptor](https://doc.qt.io/qt-5/qwebengineurlrequestinterceptor.html) to return an user agent based on the top-level and request URL.\r\n\r\n# Other headers\r\n\r\n- Use case: ?\r\n\r\n## QtWebKit\r\n\r\nWe can set those in `createRequest` based on the resource URL.\r\n\r\n## QtWebEngine\r\n\r\nWe can set those with a `QWebEngineUrlRequestInterceptor` based on the resource and top-level URL.\r\n\r\n# Requests\r\n\r\n- Use case: uMatrix-like functionality, not loading JS/images/... at all where it's not allowed.\r\n\r\n## QtWebKit\r\n\r\nWith [QNetworkAccessManager::createRequest](http://doc.qt.io/archives/qt-5.5/qnetworkaccessmanager.html#createRequest) we can get the [QNetworkRequest](http://doc.qt.io/archives/qt-5.5/qnetworkrequest.html). However, we can't really get much information from there (e.g. the type of the request).\r\n\r\n## QtWebEngine\r\n\r\nWith a [QWebEngineUrlRequestInterceptor](https://doc.qt.io/qt-5/qwebengineurlrequestinterceptor.html) we can get [some infos](https://doc.qt.io/qt-5/qwebengineurlrequestinfo.html) about requests, allowing for something uMatrix-like. See #2626, #28.\r\n\r\n# Bindings\r\n\r\n- Use case: Unbinding conflicting bindings where the website has nicer ones; binding utility commands for a given page\r\n\r\nHaven't looked into that yet, but the code handling the bindings can probably just look at the current URL. This one should be backend independent.\r\n\r\nIn addition to adding new bindings, it should be possible to selectively unbind bindings for a page.\r\n\r\n# Permissions\r\n\r\n- Use case: e.g. automatically allow geolocation for OpenStreetMap\r\n\r\n## QtWebKit\r\n\r\n[QWebPage::featurePermissionRequested](http://doc.qt.io/archives/qt-5.5/qwebpage.html#featurePermissionRequested) gives us the `QWebFrame` (and thus frame URL), we can get the top-level URL from the page.\r\n\r\n## QtWebEngine\r\n\r\n[QWebEnginePage::featurePermissionRequested](http://doc.qt.io/qt-5/qwebenginepage.html#featurePermissionRequested) gives us the securityOrigin (frame URL?) and we can get the top-level URL from the page.\r\n\r\n# Proxy\r\n\r\n- Use case: Preventing proxy usage for some pages\r\n\r\n## QtWebKit\r\n\r\nTODO\r\n\r\n## QtWebEngine\r\n\r\nTODO\r\n\r\n# Other\r\n\r\n- Use case: ?\r\n\r\nSome other settings which *could* apply per-domain based on the current URL, but where it's questionable whether there's an use-case:\r\n\r\n- `aliases`\r\n- `ignore_case`\r\n- `content.host_blocking.enabled` (to selectively turn off adblocking)\r\n- `content.host_blocking.whitelist` (could be merged into `.enabled` with top-level/origin URL?)\r\n- `content.javascript.alert` / `.log` / `.prompt`\r\n- `downloads.location.*`\r\n- hints settings? Probably `hints.*_regexes` at least.\r\n- input settings (`forward_unbound_keys`, etc.)\r\n- `zoom.default`\r\n- colors/fonts?\r\n"},"comment":{"url":"https://api.github.com/repos/qutebrowser/qutebrowser/issues/comments/376332328","html_url":"https://github.com/qutebrowser/qutebrowser/issues/3636#issuecomment-376332328","issue_url":"https://api.github.com/repos/qutebrowser/qutebrowser/issues/3636","id":376332328,"user":{"login":"beta-phenylethylamine","id":36526063,"avatar_url":"https://avatars3.githubusercontent.com/u/36526063?v=4","gravatar_id":"","url":"https://api.github.com/users/beta-phenylethylamine","html_url":"https://github.com/beta-phenylethylamine","followers_url":"https://api.github.com/users/beta-phenylethylamine/followers","following_url":"https://api.github.com/users/beta-phenylethylamine/following{/other_user}","gists_url":"https://api.github.com/users/beta-phenylethylamine/gists{/gist_id}","starred_url":"https://api.github.com/users/beta-phenylethylamine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beta-phenylethylamine/subscriptions","organizations_url":"https://api.github.com/users/beta-phenylethylamine/orgs","repos_url":"https://api.github.com/users/beta-phenylethylamine/repos","events_url":"https://api.github.com/users/beta-phenylethylamine/events{/privacy}","received_events_url":"https://api.github.com/users/beta-phenylethylamine/received_events","type":"User","site_admin":false},"created_at":"2018-03-26T22:27:53Z","updated_at":"2018-03-26T22:27:53Z","author_association":"NONE","body":"I'm not familiar with QtWebEngine, but is it possible to intercept and edit requests sent by it? That would allow you to just \"wipe\" the cookies it's sending with the request. You'd need to inject some javascript to block getting them via javascript too I guess, but that would probably be a \"more elegant\" solution than trying to fight QtWebEngine for it"}}
{"actor":{"display_login":"beta-phenylethylamine"}}