How to get notified when user clicked anywhere in a webpage - javascript

I want to build a extension similar to Chrome dictionary . For building that i my extension should be notified when user left clicked on a webpage on any tab.
I searched all over the chrome.* APIs but failed to find that kind of event. Also tried googling with this query : "how to get notified when user clicks on a webpage in chrome api". Failed to get any result.
Is this prohibited in chrome api ? I found that Extensions can't listen to tabs and navigation buttons but as far as i understand that is not relevant with my issue.
Any suggestion in how to get this done is highly appreciated.

You'll need to attach a content script to all pages
Google Chrome Extensions: Content Scripts
In that script attach a listener to the document to catch all clicks (like #Jashwant said) then pass a message back to your extension to perform some behaviour:
Google Chrome Extensions: Message Passing

Related

Ways to notify/alert the user in Firefox's WebExtensions

I'm developing cross-browser extension using WebExtensions API. It's focused on monitoring some HTTP request and blocking potentially malicious ones. I need to get user input for each blocked host (because it could have been falsely blocked and user might want to unblock it right away). Originally I wanted to use popup, but then I found out, that popups are only allowed to be thrown up in User Action event handler, which is a problem, I need to to that independently on the user's action. After that I found second option - the Chrome's notification API. But again, found out, that Firefox does not implement buttons in notifitacions (even though Chrome does). OnClicked event is supported for notification, but that's not enough (mainly because of users accidentally clicking on the notification to close it).
TL;DR - Looking for a way to alert/notify user and get the input from him by clicking on one of two presented buttons. Popups and Notifications does not seem like sufficient way.
Can you suggest ways to implement desired behaviour?
Possible solutions:
1) Injecting content script that implements popup window and communicates via messages with bacgkround script.
2) Simulating animation of extension's icon to draw user's attention.

Close popup in chrome while dom is getting loaded

I am using the latest version of selenium web driver and google chrome browser.
In my app, after clicking on login button while dom is getting loaded I get a popup
image
I just want to close this popup without entering any value. I am using java for scripting.
I tried javascript executor, all popup handlers from selenium but not able to close the same. I am not able to shift control on the popup window.
I google a lot but didn't found any relevant code
This is a default behavior when using HTTP basic authentication. To stop this window to come you would need to send user and password in the request. Or as I understand from other response I found about this you can write:
driver.get("http://UserName:Password#Example.com");
There seems to be a similar issue, going on in thread: How to handle authentication popup with Selenium WebDriver using Java
If all you want to do is "Cancel" the popup, instead of entering credentials. You may be able to just use this.
driver.switchTo().alert().dismiss();
using AutoID was able to resolve above issue.
Refernce: http://learn-automation.com/handle-windows-authentication-using-selenium-webdriver/

System tray icon for Chrome extension

My manifest includes a nice icon and my background.js page triggers the extension's main functionality.
Is there some easy way to get the exact same functionality within the notification tray? In other words, is there any way to put an icon in the task bar (like google does with the hangouts extension), and trigger a single event when it is clicked.
Here is the code I use for the action button in the browser itself:
chrome.browserAction.onClicked.addListener(function(tab)
{
mainFunction();
});
I'd imagine there is a simple addition to the manifest along with a simple line like the above, that would achieve my desired result.
Chrome extensions don't have access to the system tray, and there is no API for that.
Hangouts is specifically whitelisted in the Chromium source code to get some special privileges.

USING iMACROS to monitor/record HTTP requests (image request) after running Javascript?

I am working on a project to find a tool or solution solution with iMacros that will allow me to automate a large portion of regression testing on our site. The main scenario that I'm trying to make work goes like this:
Use tool iMacros to go through a set of actions - in this case,
a) Visit site
b) Login to site
c) Use search bar on screen to search for product
After the search page loads, there is a header that I need to verify. For this particular scenario, the expected result is "v1=header".
If I were not trying to make a macro from this, I could easily manually find it and observe (i.e. pressing F12 in Chrome, clicking "Network", sorting by the term "b/ss" and finding the "v1=" from the list after the search page loads.
What I cannot seem to do is to record this action, then reply it later and record the results. I am currently evaluating iMacros, by itself and with the Firefox add-on and Chrome extension. iMacros seems to be the answer to this...but all of my searches on how I would make iMacros do exactly this has not been forthcoming.
So far I have tried:
(Chrome) Pressing F12 in window and in its own window - iMacros would not respond to anything done within that window
(Firefox) Recording clicks and button presses while using HTTPFox when viewing the results - again, iMacros would not respond to anything in that window
Having iMacros take a screenshot while HTTPFox was open with the information I was looking for - the screenshot only showed the page without the HTTPFox information.
Considering I have very little experience with html and javascript, I'm running out of options to search for. Anything that anyone can come up with would be greatly appreciated. Thank you in advance for your time.
Determined that iMacros does not have the capability to do what is needed, and will not recognize any web dev panel (firebug, httpfox, etc) when recording macros or screenshots.
Utilized approxiblue's suggesting to check out Selenium (Webdriver), which after a week of code-surgeoning with examples from various sites, was able to piece together a combo of Webdriver/Firefox/Firebug/NetExport to listen to the http requests when performing a search and then exporting the events to a .HAR file.

Detect if user have my Chrome extension installed?

I started to work on a very cool Chrome extension and I ran into a little problem.
I want to allow my user to share a link. By sharing this link, other users can get some information with my extension.
The problem is when a user click on the shared link, I want to check if my Chrome extension is installed on his browser. If it does - great, else - I want to redirect him to download my extension.
Any ideas how to?
One possibility is to have your extension run a content script on all sites* and add a listener for click events on document. It would check event.target to make sure it's a link and has a particular prefix, and if it does, it would call the preventDefault method of its parameter and do its stuff. For users without your extension, the link would of course work like any other.
*This causes Chrome to warn your potential users about this when they install your extension; read Permission Warnings for more information.
Make the extension add an invisible element to the DOM of every page that it loads, marking it with a unique ID. When the user clicks on that link, run some javascript to check for that element -- if it doesn't exist, then you know the extension hasn't been installed.
I think you should be able to set/modify headers in the HTTP requests (as of Chrome 17?). Adding a header to requests would mean you can detect the presence of the extension on the server side.
This is fairly unintrusive. Many extensions/plugins have historically modified the User-Agent header.

Categories