Overriding web application keyboard shortcuts - javascript

I think this question is going to be rare, hence enjoyable for some. I have two products - Salesforce's Developer Console & Google Chrome.
Google Chrome has built in hotkey - ctrl + page up/down to switch tab.
Unfortunately Salesforce's Developer Console uses the same hotkey to switch between tabs within console.
Now I will contact Salesforce support and maybe 3-6 months later they will fix the problem. I suppose contacting Google for support is ...
I have tried Shortcut Manager extension for Chrome but it does not have the option to disable the mentioned hotkey.
I was thinking wether it would be possible to overwrite the integer value in keyCode in Salesforce's script?
I've read somewhere that browser Extensions do not have such access. Not sure whether that is true, but then perhaps something like Privoxy could work?
Thank you all.

To enable and customize keyboard shortcuts:
From Setup, click Create | Apps.
Click Edit next to a Salesforce console app.
Click Customize keyboard shortcuts.
Click Edit on the top of the page.
Select Enable keyboard shortcuts.
Edit an existing keyboard shortcut or create a new one:
To edit a shortcut, click Edit next to the shortcut, type the combination of key commands to use, and click OK.
To create a shortcut, click +Add Keyboard Shortcut, type the action the shortcut will perform, a Console Event Name, which is a unique identifier, the combination of key commands to use, and click OK. For the new shortcut to work, you must send the Console Event Name to the developer who defined your shortcut’s action so that he or she can add it to the method that will trigger your shortcut.
To deactivate a shortcut, deselect Active next to the shortcut’s name. You can’t delete the default shortcuts provided by Salesforce, but you can edit or deactivate them.
Click Save.
More info here.

Related

How to prevent outside JavaScript event handlers from being triggered from a Shadow DOM?

I am trying to create a Chrome extension that is toggled via keyboard shortcut. The keyboard shortcut brings up a ShadowDOM that contains a search bar (similar to spotlight search). The problem I am getting is some key presses (e.g. the key 's' on GitHub) will trigger a javascript action on the native webpage (in this case, selecting GitHub's own search bar).
Does anyone know of a way to disable outside JavaScript events, and/or a way to do this via Chrome Extension?

Bookmarklet for enabling the Chromevox extension

The Chromevox extension hijacks my letter "a" so that it activates and deactivates my enabled Chromevox extension. That means if I'm typing something, everytime I hit the letter "a" Chromevox does something. So I need to disable the Chromevox extension when I'm not using it. Opening the extension maanager for this is a pain. I'd like to have a custom keyboard shortcut or bookmarklet to toggle Chromevox enabled or disabled. I think the javascript
chrome.management.setEnabled(string id, boolean enabled, function callback)
should do it, but I don't know how to find the string. Any ideas? I'm running Pop!_OS 20.04 which is more or less Ubuntu 20.04.
As so often happens, I figure out a solution right after posting. If you turn the extension on, from within the extension manager page, there is a hamburger menu. Press that and choose keyboard shortcuts. There are a number of shortcuts for Chromevox. The last on is toggle Chromevox classic. Change "In Chrome" to "Global." When you hit the shortcut, it changes the Chromevox key; so that now you can type without problems. When you are done typing, use the same shortcut to go back.

Chrome auto tab discarding disable java script?

Chrome implement new feature which is called auto tab discarding through this feature enable user when user not on the tab that tab will discard and when user re click on that tab chrome auto refresh that tab. here is the link of Article. this is is very good feature But my problem is I'm showing notification when our tab is active in chrome but because of this feature our Tab is discard and not able to show notifications anymore.
My Question is :- How to Disable this feature or there is any way to keep my tab active or any way to prevent that from discarding?
Users can switch off automatic tab discarding by setting the respective flag in Chrome using this link: chrome://flags/#automatic-tab-discarding
But every page with states depending on user input do have the same problem like yours. Usually, you can prevent unloading a page with handling the onbeforeunload event in JavaScript. Unfortunately, Google does not prevent a solution for this on all systems, despite many users had problems with this feature already in the experimental phase, as you can read in the user comments:
https://developers.google.com/web/updates/2015/09/tab-discarding
For ChomeOS, the problem seams to be fixed:
https://bugs.chromium.org/p/chromium/issues/detail?id=123049
On Android, automatic tab discarding is quite aggressive and prevents using Chrome for applications with significant user input, imho.
On Windows, automatic tab discarding only starts if the available memory is low.
Sorry for not coming up with a proper solution here (I'd be really happy to have one) - I did extensive research and this is all I could find.

Disable mobile Chrome 43's "Touch to Search" feature programmatically

When I select text in Chrome 43 on my Android device I get the "Touch to Search" popup. We're currently using text selection for a feature on our site and this new Chrome feature interferes with some of our UI.
In the long run, we'll be working out new UI/UX to work side-by-side with this feature, but in the interim, we want to disable it on our web app.
Is there some sort of meta tag or JavaScript we can add to turn this off? Does anyone know if this is currently possible?
This can be manipulated in a number of ways. The user can turn it off in flags as PaulI suggested, and you can control it.
Developer control, right now there are a couple of options but the basic summary is if we think it is an user interactable element then it won't be enabled:
CSS: -webkit-user-select: none;
HTML:
Anything with an aria-role will not have the touch to search enbabled
Anything with a tabindex of -1 or > 0
Possible workaround could be to wrap text in <button> tag. This obviously wouldn't work if talking about big blocks of text, but for other elements like titles, icons and other small stuff this works fine.
As of 2021, it isn't possible to disable touch-to-search (when this is triggered by a long-press for text selection) in chrome mobile. The article that Kinlan is referencing is apparently concerned only with touch-to-search triggered through a tap gesture.
Quoting donnd, from bugs.chromium.org:
Regarding #2 -- developer control: The 2015 article that you mentioned (https://developers.google.com/web/updates/2015/10/tap-to-search) focuses on triggering through the tap gesture. As you correctly point out, it does not address the long-press gesture triggering. Touch to Search responds to both tap and long-press but treats them differently. As I'm sure you know, the long-press gesture activates a whole set of features which can include copy, translation, smart text selection, and Web Search. A site developer can markup their page text as non-selectable in order to disable the long-press gesture entirely, but currently there's no way to disable only the Touch to Search response to long pressing. If you'd like to work with us to add such a feature, let us know and we'll file a separate feature request.
If you want disabled "touch to search" in a menu that has an action open / close (toggle), it is necessary to javascript :
event.preventDefault();
Navigate to about:flags or chrome:flags and look for Enable Contextual Search
Then toggle to Disabled and hit restart at the bottom.

What percentage of followed hyperlinks might have their "onclick" JavaScript ignored?

As far as I know all popular web browsers execute the onclick attribute of an anchor link first, then follow the path specified by the href attribute.
The problem here is that the onclick attribute only gets called when clicking with the left mousebutton (without pressing ctrl or shift for a new tab or window) or when pressing enter on your keyboard while the tabIndex is set to the link you want to follow.
But there are many other ways of following a link than just those two.
Ctrl + click
shift + click
rightmousebutton + open
rightmousebutton + new tab
drag & drop link to address bar
and so on...
My client uses onclick for conversion statistics. Which seems heavily unreliable.
My question:
What percentage of hyperlinks are being followed without activating their onclick attribute?
All estimates are highly appreciated. I'm completely lost; I think it can be any number...
Aside from those of us who habitually middle-click/ctrl-click to open links in new tabs, there's another major cause of onClick failure: NoScript and similar plugins which allow javascript to run only when it comes from whitelisted sites. If your domain isn't on my whitelist, then your onClick won't run, no matter how I trigger the link.
If you want reliable stats on which pages people are visiting, there's only one bulletproof source for that: The web server logs.
The logs are probably also your best bet for tracking how people move throughout the site, but they're not entirely reliable, as some privacy-paranoid users will falsify their referer headers or just not send them at all, but I expect that to be far less common than disabling javascript.
It depends. If the audience is more technically inclined, I'd assume that using alternative ways of following a link would be more common. All in all, though, even a lot of technical people seem to be unaware of things like clicking the middle mouse button to open or close a tab. If that's the case with technical people, I wouldn't be surprised if almost no one in the general audience used it.
The links are all exit-links. I was thinking of a PHP script that does the counting of clicks.
Though this is not the subject of your question, you might want to have a look at Google Analytics then. They are The Master in tracking you. They track right-clicks (even when not actually selecting "open in new window" after that, which they obviously cannot know), which will yield Ajax calls to http://www.google.com/url.
To see Analytics in action: with Adblock and the like disabled, search something on google.com and open up Live HTTP Headers in Firefox (or your Firebug Net tab in Firefox, or WebKit's Resources pane in Safari or Chrome, sorted by time). Next, click, right-click, shift-click or control-click any search result (preferably a result that does not require a lot of HTTP traffic by itself, or is in your browser's cache).
the onclick attribute only gets called when clicking with the left
mousebutton (without pressing ctrl or shift for a new tab or window)
Not entirely true. I created a quick test at JS Bin, to show that modifier keys do not affect the onclick event. (For right-click, one should use the oncontextmenu event.)
What are you doing in your onclick handler that you are worried about not working? e.g. if you have a regular link to a page... and the onclick just opens that same page in a pre-sized popup for user convenience in a web application... then there's likely no issue (e.g. CTRL+Click) still opens the page, it just gets opened in a new tab)
If you are just trying to "log" every click in the site/application for tracking purposes then maybe you can hook into the onmousedown/up or focus/blur events instead/also.

Categories

Resources