New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Per domain settings #27

Closed
The-Compiler opened this Issue Oct 1, 2014 · 64 comments

Comments

Projects
@The-Compiler
Collaborator

The-Compiler commented Oct 1, 2014

For all settings where this makes sense, the setting should be configurable per domain (or probably even protocol/domain/port triple).

This will make a lot of things easier:

  • NoScript is essentially done then
  • RequestPolicy is a lot easier
  • etc.

@The-Compiler The-Compiler self-assigned this Oct 1, 2014

@Ram-Z

This comment has been minimized.

Show comment
Hide comment
@Ram-Z

Ram-Z Dec 15, 2014

Contributor

This also deals with custom stylesheets.

IMHO it's best to configure with regexes against the entire URI.

Contributor

Ram-Z commented Dec 15, 2014

This also deals with custom stylesheets.

IMHO it's best to configure with regexes against the entire URI.

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Feb 25, 2015

Collaborator

#499 should be done first. Setting the milestone to v0.3 as I really want to see this, but should get v0.2 out first.

Collaborator

The-Compiler commented Feb 25, 2015

#499 should be done first. Setting the milestone to v0.3 as I really want to see this, but should get v0.2 out first.

@iggy

This comment has been minimized.

Show comment
Hide comment
@iggy

iggy Mar 29, 2015

Contributor

A nice addition to this would be "force https per domain".

Contributor

iggy commented Mar 29, 2015

A nice addition to this would be "force https per domain".

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Mar 29, 2015

Collaborator

@iggy - also see #335 for that :)

Collaborator

The-Compiler commented Mar 29, 2015

@iggy - also see #335 for that :)

@The-Compiler The-Compiler referenced this issue May 18, 2015

Open

uMatrix #28

@The-Compiler The-Compiler modified the milestones: soon, v0.3 Jun 16, 2015

This was referenced Sep 16, 2015

@The-Compiler The-Compiler removed their assignment Oct 1, 2015

vyp added a commit to vyp/dots that referenced this issue Nov 21, 2015

feat(qutebrowser): override some fonts to use default selections via css
stylesheet

Of course, this means that attempting to use any of these fonts on *any*
site will result in it being replaced with the selections here.

Ideally this should only be done on particular sites as seen fit. This
can be fixed when qutebrowser gains the ability to have per-domain
settings [1].

[1]: qutebrowser/qutebrowser#27

@The-Compiler The-Compiler modified the milestones: config revolution, soon Nov 25, 2015

@rcorre

This comment has been minimized.

Show comment
Hide comment
@rcorre

rcorre Mar 20, 2016

Collaborator

from the mailing list discussion: per-domain user-agents would be useful (right now I need one user-agent for google hangouts and another for github).

Collaborator

rcorre commented Mar 20, 2016

from the mailing list discussion: per-domain user-agents would be useful (right now I need one user-agent for google hangouts and another for github).

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler May 13, 2016

Collaborator

Note to myself so this doesn't get lost; a hack to use possibly use a QWebEngineUrlRequestInterceptor per page (e.g. for headers):

16:59 <The-Compiler> carewolf, Emdek: Looking at QTBUG-53372 I wonder... would it be possible/useful to be able to attach an arbitrary identifier (say, a QString, think e.g. UUID) to a request (and sub-requests?) to be able to identify them in different places, like in a QWebEngineUrlRequestInterceptor?
16:59 <qt_gerrit> carewolf, Custom load options - https://bugreports.qt.io/browse/QTBUG-53372 (Reported)
16:59 <The-Compiler> just brainstorming here though :)
17:00 <@carewolf> you could just put anything in there already, and rewrite them in the interceptor if you want
17:01 <The-Compiler> carewolf: put anything in where?
17:02 <@carewolf> you can use invalid URLs and rewrite them to something valid
17:02 <@carewolf> I think (haven't tried)
17:03 <The-Compiler> that's... horrib... eh, I mean really clever.
17:03 <The-Compiler> ;)
17:04 <@carewolf> You can look at NavigatorController:LoadURLParams for what we can pass to Chromium
Collaborator

The-Compiler commented May 13, 2016

Note to myself so this doesn't get lost; a hack to use possibly use a QWebEngineUrlRequestInterceptor per page (e.g. for headers):

16:59 <The-Compiler> carewolf, Emdek: Looking at QTBUG-53372 I wonder... would it be possible/useful to be able to attach an arbitrary identifier (say, a QString, think e.g. UUID) to a request (and sub-requests?) to be able to identify them in different places, like in a QWebEngineUrlRequestInterceptor?
16:59 <qt_gerrit> carewolf, Custom load options - https://bugreports.qt.io/browse/QTBUG-53372 (Reported)
16:59 <The-Compiler> just brainstorming here though :)
17:00 <@carewolf> you could just put anything in there already, and rewrite them in the interceptor if you want
17:01 <The-Compiler> carewolf: put anything in where?
17:02 <@carewolf> you can use invalid URLs and rewrite them to something valid
17:02 <@carewolf> I think (haven't tried)
17:03 <The-Compiler> that's... horrib... eh, I mean really clever.
17:03 <The-Compiler> ;)
17:04 <@carewolf> You can look at NavigatorController:LoadURLParams for what we can pass to Chromium
@haasn

This comment has been minimized.

Show comment
Hide comment
@haasn

haasn Nov 15, 2017

Contributor

@The-Compiler thanks for the pointers; this works very well:

diff --git a/qutebrowser/browser/webkit/webpage.py b/qutebrowser/browser/webkit/webpage.py
index 7e1d991b9..fec6d0f49 100644
--- a/qutebrowser/browser/webkit/webpage.py
+++ b/qutebrowser/browser/webkit/webpage.py
@@ -366,11 +366,19 @@ class BrowserPage(QWebPage):
 
     def userAgentForUrl(self, url):
         """Override QWebPage::userAgentForUrl to customize the user agent."""
-        ua = config.val.content.headers.user_agent
+
+        special_agents = {
+            # Infinite redirect loop / garbage otherwise
+            'twitter.com': 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html',
+        }
+
+        ua = special_agents.get(url.host())
         if ua is None:
-            return super().userAgentForUrl(url)
-        else:
-            return ua
+            ua = config.val.content.headers.user_agent
+        if ua is None:
+            ua = super().userAgentForUrl(url)
+
+        return ua
 
     def supportsExtension(self, ext):
         """Override QWebPage::supportsExtension to provide error pages.

Now twitter links work again, for starters. :p Honestly this seems useful enough that I wonder if perhaps the user_agents thing couldn't just (easily?) be turned into a host/agent dictionary in the qutebrowser settings using essentially the same code. This would solve the problem for me and perhaps some others.

Contributor

haasn commented Nov 15, 2017

@The-Compiler thanks for the pointers; this works very well:

diff --git a/qutebrowser/browser/webkit/webpage.py b/qutebrowser/browser/webkit/webpage.py
index 7e1d991b9..fec6d0f49 100644
--- a/qutebrowser/browser/webkit/webpage.py
+++ b/qutebrowser/browser/webkit/webpage.py
@@ -366,11 +366,19 @@ class BrowserPage(QWebPage):
 
     def userAgentForUrl(self, url):
         """Override QWebPage::userAgentForUrl to customize the user agent."""
-        ua = config.val.content.headers.user_agent
+
+        special_agents = {
+            # Infinite redirect loop / garbage otherwise
+            'twitter.com': 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html',
+        }
+
+        ua = special_agents.get(url.host())
         if ua is None:
-            return super().userAgentForUrl(url)
-        else:
-            return ua
+            ua = config.val.content.headers.user_agent
+        if ua is None:
+            ua = super().userAgentForUrl(url)
+
+        return ua
 
     def supportsExtension(self, ext):
         """Override QWebPage::supportsExtension to provide error pages.

Now twitter links work again, for starters. :p Honestly this seems useful enough that I wonder if perhaps the user_agents thing couldn't just (easily?) be turned into a host/agent dictionary in the qutebrowser settings using essentially the same code. This would solve the problem for me and perhaps some others.

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Nov 15, 2017

Collaborator

I really haven't heard of people needing per-domain user agents much with QtWebEngine (and neither with QtWebKit 5.212). I'm not really keen on having a temporary half-baked solution for this which gets removed again as soon as per-domain settings are in.

Collaborator

The-Compiler commented Nov 15, 2017

I really haven't heard of people needing per-domain user agents much with QtWebEngine (and neither with QtWebKit 5.212). I'm not really keen on having a temporary half-baked solution for this which gets removed again as soon as per-domain settings are in.

@SirCmpwn

This comment has been minimized.

Show comment
Hide comment
@SirCmpwn

SirCmpwn Dec 5, 2017

fwiw I'm not in it for per-domain user agents, but per-domain JavaScript toggles, macros/keybindings, etc

SirCmpwn commented Dec 5, 2017

fwiw I'm not in it for per-domain user agents, but per-domain JavaScript toggles, macros/keybindings, etc

@MichaelMackus

This comment has been minimized.

Show comment
Hide comment
@MichaelMackus

MichaelMackus Dec 8, 2017

I agree. The main use-case for this for me would be a NoScript-like setup. Is there any way to hack the enable javascript setting like @haasn did here?

MichaelMackus commented Dec 8, 2017

I agree. The main use-case for this for me would be a NoScript-like setup. Is there any way to hack the enable javascript setting like @haasn did here?

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Dec 8, 2017

Collaborator

Probably not as easily as there isn't a simple mechanism for per-domain settings in QtWebKit/QtWebEngine, qutebrowser needs to adjust them at the right point in time by itself.

Collaborator

The-Compiler commented Dec 8, 2017

Probably not as easily as there isn't a simple mechanism for per-domain settings in QtWebKit/QtWebEngine, qutebrowser needs to adjust them at the right point in time by itself.

@The-Compiler The-Compiler modified the milestones: v1.1.0, v1.2.0 Jan 15, 2018

@tidux

This comment has been minimized.

Show comment
Hide comment
@tidux

tidux Jan 19, 2018

Something else needed for full uBO-equivalent functionality: gorhill/uBlock#3374

tidux commented Jan 19, 2018

Something else needed for full uBO-equivalent functionality: gorhill/uBlock#3374

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Jan 20, 2018

Collaborator

@tidux That seems unrelated to per-domain settings and would probably better fit in #29. The domains should probably be submitted to the blocklists qutebrowser uses. Also, note that this probably applies to qutebrowser too:

For Chromium-based browsers, there is no solution until their extensions API allows for modifying the response body data on the fly.

Collaborator

The-Compiler commented Jan 20, 2018

@tidux That seems unrelated to per-domain settings and would probably better fit in #29. The domains should probably be submitted to the blocklists qutebrowser uses. Also, note that this probably applies to qutebrowser too:

For Chromium-based browsers, there is no solution until their extensions API allows for modifying the response body data on the fly.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jan 22, 2018

Would it be possible to disable remote fonts per domain? If so, would it also be possible to disable them by default and then enable them per domain? Or is it impossible because the backend handles that?

ghost commented Jan 22, 2018

Would it be possible to disable remote fonts per domain? If so, would it also be possible to disable them by default and then enable them per domain? Or is it impossible because the backend handles that?

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Jan 22, 2018

Collaborator

@Zekario Should be possible with QtWebEngine, see #2626.

Collaborator

The-Compiler commented Jan 22, 2018

@Zekario Should be possible with QtWebEngine, see #2626.

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Feb 20, 2018

Collaborator

Sooo... good news! After some hard work over the past few days, this is now nearly ready! 🎉

whoa

It still has some issues (like needing a refresh for some settings with QtWebEngine), and only supports a few settings (search for "pattern"). However, I think it's ready to merge in this stage with further improvements coming later after it's in the master branch.

If you want to try it out (and I'd love some feedback!), check the per-url branch. Note that you should back up your ~/.config/qutebrowser/autoconfig.yml as it'll be migrated to a format the master branch can't read.

Collaborator

The-Compiler commented Feb 20, 2018

Sooo... good news! After some hard work over the past few days, this is now nearly ready! 🎉

whoa

It still has some issues (like needing a refresh for some settings with QtWebEngine), and only supports a few settings (search for "pattern"). However, I think it's ready to merge in this stage with further improvements coming later after it's in the master branch.

If you want to try it out (and I'd love some feedback!), check the per-url branch. Note that you should back up your ~/.config/qutebrowser/autoconfig.yml as it'll be migrated to a format the master branch can't read.

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Feb 21, 2018

Collaborator

I now opened a PR for this: #3618 - if you have the time to take a look at it (code/functionality), please do!

Collaborator

The-Compiler commented Feb 21, 2018

I now opened a PR for this: #3618 - if you have the time to take a look at it (code/functionality), please do!

@MichaelMackus

This comment has been minimized.

Show comment
Hide comment
@MichaelMackus

MichaelMackus Feb 21, 2018

Sweet! Now that my favorite FF extensions are being abandoned/watered down I'm waiting for this to make qutebrowser my full time browser.

MichaelMackus commented Feb 21, 2018

Sweet! Now that my favorite FF extensions are being abandoned/watered down I'm waiting for this to make qutebrowser my full time browser.

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Feb 25, 2018

Collaborator

It's been a while™, but this is finally ready and merged into master! 🎉 I think I found workarounds for most annoying issues I've found (such as needing to reload manually to turn on/off JS). If you notice some issues, please let me know!

The remaining bits are split across various issues:

  • #3622 (various small remaining issues)
  • #2626, #3636 (support for more settings) (nice issue IDs 😆)
  • #28 (support for a second URL in settings, uMatrix-/request-policy like)
Collaborator

The-Compiler commented Feb 25, 2018

It's been a while™, but this is finally ready and merged into master! 🎉 I think I found workarounds for most annoying issues I've found (such as needing to reload manually to turn on/off JS). If you notice some issues, please let me know!

The remaining bits are split across various issues:

  • #3622 (various small remaining issues)
  • #2626, #3636 (support for more settings) (nice issue IDs 😆)
  • #28 (support for a second URL in settings, uMatrix-/request-policy like)
@dessalines

This comment has been minimized.

Show comment
Hide comment
@dessalines

dessalines Apr 28, 2018

how do you actually use this then? I'd like to set custom css for a specific site.

dessalines commented Apr 28, 2018

how do you actually use this then? I'd like to set custom css for a specific site.

@jgkamat

This comment has been minimized.

Show comment
Hide comment
@jgkamat

jgkamat Apr 28, 2018

Collaborator

Right now stylesheets dosen't have patterns implemented, see #3854.

There's examples on setting pattern settings in the configuration documentation, for both :set and config.py. Whether a setting supports patterns is visible on it's :help page.

Collaborator

jgkamat commented Apr 28, 2018

Right now stylesheets dosen't have patterns implemented, see #3854.

There's examples on setting pattern settings in the configuration documentation, for both :set and config.py. Whether a setting supports patterns is visible on it's :help page.

@jcjordyn130

This comment has been minimized.

Show comment
Hide comment
@jcjordyn130

jcjordyn130 Apr 28, 2018

jcjordyn130 commented Apr 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment