Skip to content
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

Question regarding automatic url redirection #3933

Closed
qutetemp opened this issue May 20, 2018 · 7 comments
Closed

Question regarding automatic url redirection #3933

qutetemp opened this issue May 20, 2018 · 7 comments
Labels
status: needs triage Issues/PRs which need some deeper investigation.

Comments

@qutetemp
Copy link

Is there any way I can redirect a domain to another domain ?
Like for example I want to automatically redirect all {string}.reddit.com/{etc} to i.reddit.com/{etc}

@jgkamat
Copy link
Member

jgkamat commented May 20, 2018

Currently, there's no way to do this built-in. Some people have userscripts which rewrite target urls on the page (for example, youtube->hooktube), but the userscripts that I've seen have been fairly rudementary (and better ones could be made).

You could also override the :open command through the config.py system (unsupported).

@qutetemp
Copy link
Author

The userscript option isn't really that great for me since I'm on qtwebkit and I'm not sure I understand the second suggestion.
Is it unsupported because it is not possible or is it unsupported because it's not recommended. I know there are aliases but they don't accept patterns ( I might be wrong ) and that would not solve the case of opening links from inside a page.

@jgkamat
Copy link
Member

jgkamat commented May 20, 2018

er, sorry, I messed up terminology:

There are rewriting greasemonkey scripts (not userscripts), which should work on qtwebkit and webengine (although I haven't tried). Here is one. The reason why I don't like this approach is that the userscripts I've seen aren't well designed, and don't take into account changes on the page by js. The script would have to set up a mutationobserver or something similar.

I think this might be possible to implement, there's no facility for doing this right now. The implementation would probably be similar to this PR: https://github.com/qutebrowser/qutebrowser/pull/3864/files (in that it would have to block a request that matches and fire a new, translated one).

@qutetemp
Copy link
Author

Yes sorry I think it's actually my fault because I did not provide the reason why qtwebkit is an impediment and I'm under the impression that userscript and greasemonkeys scripts are the same thing. I would very much appreciate if you could provide me with something to read regarding the difference. Aren't greasemonkey scripts just usercripts that target that specific browser addon ?
I'm also under the impression that on qtwebkit userscripts / greasemonkey scripts load after and not before the actual site loads/starts loading.
I've encountered this behaviour with 4chan X some time ago

@jgkamat
Copy link
Member

jgkamat commented May 21, 2018

Unfortunately "userscript" is an overloaded term:

qutebrowser uses "userscript" in the dwb sense, which is a way of creating simple scripts that control qutebrowser. they are documented here.

Greasemonkey is a separate concept, which is (outside of qb) sometimes referred to as userscripts, which is essentially js running in the page. There's a good greasemonkey entry in the faq. Greasemonkey is just a way to run js scripts in the browser.

I think that greasemonkey scripts do run on the end of page load, but maybe support could be added for other targets like on webengine. Webkit does provide some signals such as domcreation that could be used.

@qutetemp
Copy link
Author

Thanks for the response. I'll try my hand with a userscript and I'll post here if I succeed.

@The-Compiler The-Compiler added the status: needs triage Issues/PRs which need some deeper investigation. label May 30, 2018
@The-Compiler
Copy link
Member

I think this is something which should be exposed via a plugin API (#30) once that exists. Before that (e.g. via a config), I can't think of a good way to expose this and rewrite URLs without plugin code to change the URLs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage Issues/PRs which need some deeper investigation.
Projects
None yet
Development

No branches or pull requests

3 participants