Intercept or catch a chrome click event on the interface - google-chrome

Is possible to intercept a click event on the chrome interface? I mean, not in the page that I'm visiting, but a click on a tab or a click on the "go back button", a click on the print button in the settings menu or a click on the "show all favourites button", ECC...
I cannot find anything useful in the APIs documentation.

The answer would be no, you can't directly detect the 'physical' button clicking event.
On the other side, you can listen to the request sent from the button. For example, when 'go back button' is clicked, it usually means the browser history is back, and you may refer How to Detect Browser Back Button event - Cross Browser for more info.
Please be aware that those methods may be tricky and may not be supported by every browser.

Related

Is possible to programmatically trigger the "Pause script execution" action of Chrome DevTools?

I know that I can trigger "Pause script execution" action in Google Chrome DevTools by having DevTools open with Sources tab active and press F8.
However, this seems to move focus out from the content area triggering additional events and I'm trying to debug some code that listens focus and blur events in addition to other events I'm trying to debug.
What I would really need is ability to trigger the "Pause script execution" feature without pressing F8. The closest I can do is executing setTimeout(function(){ debugger; }, 2000); in the JS console but that will stop all JS processing instantly after 2 second delay. The feature I'd like to use from DevTools is ability to delay stopping until some code actually runs so that the event queue already has the next events when scripting is stopped. (I'm basically trying to figure out what events are already in the queue in some specific situations and any extra focus/blur events will mess that work.)
Is there a way to trigger "Pause script execution" without pressing F8 or clicking the GUI button because both mess with the focus events?
It seems that to fully handle all combinations of keyboard focus and focus/blur events you need to do some extra steps. I found that I can get correct events like this:
Open DevTools and the Sources tab.
Press Ctrl+Shift+P to open "Run command" action
Search for focus and run command Emulate a focused page (note that this is not a permanent toggle and you need to do this again in the future to debug similar stuff).
Now prepare the situation you would want to test (e.g. you're about to press some keyboard button next).
Click the pause button within the DevTools Sources tab with the mouse.
Press Ctrl+Shift+P again and search for focus and run command Focus debuggee.
The keyboard focus is now in the correct place and any JS code that would be executed will trigger the debugger with the correct event for the next keyboard action.
If you need to debug mouse events, follow the same list but instead of clicking the pause button with mouse, press F8 twice (single press doesn't work for me?), then Ctrl+Shift+P again and search for "focus" and run command Focus debuggee using the keyboard only. Do not move the mouse even a single pixel after pressing F8 until you have exeuted the Focus debuggee command, or the page will see mousemove and other mouse movement related events.

Chrome extension - Is it possible to capture print dialog Print and Cancel button clicks?

In chrome, when we use Ctrl+P, print dialog will open. Here I want to record whether user has clicked on "Print" or on "Cancel". I know that there is no direct way of doing it through web application, I am thinking to implement with Chrome extensions (if there is a way). I am checking Print related APIs, but I don't find any related method to handle this scenario. Also how to attach event to the print, cancel (no proper ID or class names to these buttons) buttons which are loading in Shadow DOM.
Below are the URLs that I am verifying
chrome.printing

Chrome: find out what request is sent when click a button on the web

I could open "developer tools -> Network -> XHR" to find all request made on the current page, but what I want to figure out now is that, there is a button "Search", when I type something in the textbox and click "Search" button, a new tab is opened in Chrome, and that means the "developer tools" cannot show what request has been made when I click the "Search" button.
Is there any way to find out the request initiated by the "Search" button?
In the Network tab, there is a Preserve log checkbox, which persists the requests between reloads and page navigation. Click on XHR to filter the requests. You can view the request headers on the right-side panel after clicking on the item in the list

popup in Chrome browser action only if click on down arrow on right side of the icon

I am developing a Chrome extension with browser action. I want to make some action on clicking on browser action icon (it is easy, not a problem), and show popup if user clicks on down arrow at the right side of the icon (that is a problem). So, we will receive a functionality similar to the firefox toolbarbutton from XUL. Is it possible to do such thing with Google Chrome?
Just want to make button, like that:
button
If it is pressed on the main part - it will do something, if on the right "drop-down" part - it will show quick settings page.
But I see only single button possibility.
The entire browserAction button works as a single button. There is no way to detect if a specific area was clicked. The best you can do is either have multiple extensions each having their own button for different actions or have options in the popup that the user selects with a second click.

Detect browser "back" input for Chrome extension

I want to make a chrome extension which performs a certain action when the user enters the a "back" navigation action.
ie: they click the back button in the browser, or they swipe backwards with 3 fingers on a macbook pro, or if they enter the shortcut alt + left arrow.
How can I detect these actions? Should I create some type of listener or handler which accounts for each one individually?
You can use the webNavigation API.
Start monitoring the details for each transition type that you mentioned. And then try to do something with this information.
chrome.experimental.webNavigation.onCommitted(function(details){
console.log(details);
});