I'm completely new to chrome extensions but I've read the getting started and assembled the example from Google. I would like to build an extension that while it's active it captures middle mouse click events on mydomain.com, reads the URL , modifies it and launches the new tab with the newly created URL.
From what I understand so far I need to have a manifest.json file and a my_script.js file that will be injected in all mydomain.com page loads. Is this correct ? If yes how should I proceed next and what should I add to my manifest and javascript file to accomplish the given task. Some code examples would be much appreciated.
I've also read a couple of answers here on stackoverflow and if browserAction
is going to be used it can only be used in extension pages, so you can not use it in content scripts. That would mean I would have to place my code in the background page instead of my_script.js . Please advice how should I proceed.
Thank you
Working script solution is:
$(document).click(function(e) {
var urlToGo = window.location.href;
// middle button
if (e.which == 2) {
urlToGo = "http://google.com";
window.open(urlToGo);
e.preventDefault();
e.stopPropagation();
}
});