-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Firefox: Simulate default action for clicking links with link hints #2602
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
Conversation
Any reason to delay merging this? |
AFAIC, this is otherwise mergeable. I don't like that we have to do it or how it's done, but it does work. |
Sorry, I didn't read the PR description carefully enough. Thanks for clarifying. Yes, we need browser-branching before merging =) |
Pushed UA sniffing for Firefox (as I added a small change that gets rid of the lag when reloading the extension on FF; I can extract it out if need be. See comment on the commit for more. |
background_scripts/main.coffee
Outdated
@@ -5,6 +5,7 @@ root = exports ? window | |||
chrome.runtime.onInstalled.addListener ({ reason }) -> | |||
# See https://developer.chrome.com/extensions/runtime#event-onInstalled | |||
return if reason in [ "chrome_update", "shared_module_update" ] | |||
return if Utils.isFirefox() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why to do nothing on runtime.onInstalled
if the browser is Firefox?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-injecting our content scripts doesn't work properly (ie. doesn't activate Vimium in tabs before they've been reloaded) on Firefox, and it makes the browser lag considerably while it's doing it. It was annoying me while testing, so I disabled it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, it does fail. Thanks! Then I want to test the update notification if you haven't, in order to ensure nothing is working on Firefox.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test the update notification if you haven't
I haven't. Go for it.
@smblott-github @philc can this be merged? I've been using it (on Chrome and Firefox) for nearly 2 weeks without any problems. |
- Remove the low-level test which examines intividual modifier settings and replace it with a higher-level test which lists the relevant modes. The previous test was hard to read. - Expand the test to open *any* `href` (not just for `a` elements). Can this do any harm? Mention @mrmr1993.
I think there may be some websites which don't call
|
Good call! I wondered about these, but assumed they would spawn a new window. I've certainly never come across a spec for it not. |
Hi all, I don't know if the following information is relevant but I have noticed that this functionality doesn't work properly if you change the user-agent (tested on my Firefox Nightly 57.0a1, Linux 64bits host). I am currently using the AgentX web extension for that. This happens when I replace the user-agent with Google Chrome on MS Windows, so if I have to use this functionality I must restore the user-agent to a default value. Best regards. |
That's a serious problem. Could we figure out the browser on the background page and then inform the front end when each frame registers? |
Why not check |
Done. I've used a method which should be fairly future-proof and shouldn't break if/when Edge and Chrome adopt Mozilla's extension API additions. |
@gdh1995 I've just done some testing on this. The current behaviour matches what clicking does with the relevant modifier keys (except for |
OKay. And the new API |
content_scripts/link_hints.coffee
Outdated
clickActivator = (modifiers) -> (link) -> | ||
defaultActionsTriggered = DomUtils.simulateClick link, modifiers | ||
simulateClickDefaultAction = Utils.isFirefox() | ||
if simulateClickDefaultAction and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrmr1993. We can merge this. But I'd really appreciate it if you could find a way of avoiding repeating the modifier/new-tab logic here. That logic rightly belongs -- in my opinion -- with the various modes at the top of this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about moving it into DomUtils.simulateClick
? Since it's a workaround for that rather than specifically for link hints, there makes more sense to me.
I'll rebase and make the change -- whichever you choose -- in a little bit.
e8649b9
to
a8337e9
Compare
315d5a1
to
a8337e9
Compare
I've rebased this, moved the fix code into |
now simulate the default action to open a new tab during VHints.*.run if needed merged: * philc/vimium#2602 * philc/vimium#2681 differences: * not deal with the case of "shift=true,others=false" * it's impossible during normal processes * support <a rel~=noopener>
This makes the
LinkHints.activateModeToOpenInNew{,Foreground}Tab
commands work as expected on Firefox.Currently the flag (
simulateClickDefaultAction
) is hardcoded on, which opens tabs twice in Chrome for the affected cases. It could be an option, use UA sniffing, or both (default set by UA sniffing), so I've left it for now.@smblott-github this is a big usability win (currently FF can only open links in the current page).