How to trigger click on a button

Try with this code; it simulates a mouse left click on the element by a quick succession of mousedown, mouseup and click events fired in the center of the button: var simulateMouseEvent = function(element, eventName, coordX, coordY) { element.dispatchEvent(new MouseEvent(eventName, { view: window, bubbles: true, cancelable: true, clientX: coordX, clientY: coordY, button: 0 })); }; … Read more

chrome extension: how to send ‘keydown’ event to page’s input?

Your code is not working because jQuery’s keydown() method does not actually trigger a “real” keydown event. Instead, jQuery looks up the “bound” event handlers in jQuery.cache, and calls the corresponding functions. Since your content script’s jQuery object differs from the page’s jQuery object, invoking .keydown() doesn’t cause any action. In your case, I suggest … Read more

Chrome extension login best practices

You should always use OAuth 2.0 for authentication within extensions. Never pass the username/password because an attacker can simply steal such information. An example from Chromium regarding OAuth in extensions is Tutorial: OAuth. Additionally, there’s an experimental API available for OAuth 2.0, which is supposed to make the whole process a little easier. There’s a … Read more

How to inject javascript into Chrome DevTools itself

Usually, you cannot create a Chrome extension which injects code in a devtools page. The “Discover DevTools Companion” extension from now on, referred to as DDC is allowed to do this, because this extension is whitelisted in the source code of Chromium: (this is no longer the case) // Whitelist “Discover DevTools Companion” extension from … Read more

How do you integrate Universal Analytics in to Chrome Extensions?

There’s an issue for that on Google code: The solution is to pass analytics your own protocol check function or simply null for no checking, in an official way. This has to come after ga(‘create’, …) : ga(‘set’, ‘checkProtocolTask’, null); // Disable file protocol checking. So you don’t need to modify the original analytics.js script. … Read more