-
Notifications
You must be signed in to change notification settings - Fork 27
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
Smart keywords, "window.location.hostname" and new tabs #42
Comments
Yeah I see what you mean. It's a good point, this is a very unfortunate limitation of the javascript scheme feature. So, it's not quite ignoring the hostname part, more like the hostname is just evaluating to an empty string. So that javascript The problem is that the target browser (a new tab) is empty at the time this property's value is evaluated. Instead of checking the current browser's location, it's creating a new tab first, then loading the bookmark URL into it, which is parsing the javascript encoded in the URL, and that javascript is then checking the current browser's location — from within the new tab, where it's running. So because the javascript is loaded inside the context of a new tab instead of the current browser, the
When you just hit Enter, you're basically executing the javascript in the current selected tab. So There might be solutions or workarounds though. It might seem like we could just change the behavior in some way so that these URLs are parsed in the parent process or something. The main issue I see is that we can't make assumptions about where the execution should happen. Even in just this one example, we need to execute inside the browser in which the content should load, because that's how the google search is initiated. See where it says But we can't have it both ways. For that to successfully change the URL of the new browser, it needs to be executed inside the new browser. But that means when we query Technically I think it's possible to write a keyword bookmark in such a way that it will open a new tab, but that wouldn't have anything to do with whether a modifier key is pressed. It would just be the normal behavior of the bookmark. And that would be done by using something like Overall I just don't think the keyword bookmark feature is very practical for this kind of feature. I think an extension would have a much easier time doing something like this, though address bar extensions are quite rare. It would also be possible to make something like this with autoconfig, but it would need to be incredibly sophisticated to integrate with the urlbar. We'd need to basically let the user create a "bookmark" whose only content is parent-process JS instructions. That way we can create all the parameters before even making a new tab. But that would be quite a project. A new urlbar result provider, a new UI for creating templates, etc. I don't think I'll have enough down time to produce and maintain something so massive by myself. I'll show this to a few people and see what they think. This is a pretty open-ended idea so I'm sure there are lots of possibilities I'm not thinking of. |
Thank you so much for your well-explained and well-defined spot on explanation. |
Hey let me know if this new script does what you're looking for. You can use the same keyword bookmark, but just replace the URL field with this:
|
Man, you are a LEGEND! Thank you so much!!! It worked flawlessly :) |
Great 😊 |
Here try this instead. I improved the keyword code so it should feel more professional
|
Remind me to look into setting custom favicons for note: |
Sorry if the title doesn't make much sense, I didn't know how to explain in a short manner. A better explanation would be, Firefox has the smart keyword thing, where you can associate some shortcuts and there are several codes you can apply to it. Like for instance, this one here, which searches the current site you are in on Google:
javascript:location.href=('http://www.google.com/search?q=site:'+window.location.hostname+'%20%s')
01.mp4
So for instance, if I'm on hackernews, and press "s" [my search term] + enter, the command automatically does a google search on that page.
The thing that is that, if instead "enter", I pressed "shit+enter", to do the same thing I wanted to do previously, but instead opening the that search on a new tab, it doesn't work, it ignores the "window.location.hostname" part, so therefore you end up with something like this:
02.mp4
I couldn't find any bugzilla report on this, actually, I'm not even sure if is a bug to be fair, but is something that it might break some people workflow. Anyway, I was wondering if it would be possible to make, sorta firefox use that "window.location.hostname" reference even when pressing shit+enter so that you can perform that search and open it on a new tab.
Or maybe you know some other workaround through this issue, like through some editing on the very smartkeywords that I'm not seeing. I would also be interesting on that.
Also, as always sorry to bother you. And thanks in advance for any help or advice.
The text was updated successfully, but these errors were encountered: