0

I'm not very familiar with browser extensions and before I begin to deeply explore them I have a few questions.

Let's say the extension injects JavaScript in the current website the user is visiting (if that's even possible). That injected JavaScript code will get, let's say the current URL for example purposes, and send it and store it on a database. Next time the user visits the same website, the user will get an extension notification informing that is the second or third or X time he or she has visited the same website.

Now that I have gave you the scenario, is the following possible? Injecting JavaScript from a browser extension to the current visiting website. If so, can I make some AJAX communication with the JavaScript and a PHP server?

  • Are you sure you need an external database? Local storage can keep track of this on an individual computer. – Teepeemm Jun 08 '14 at 12:31

1 Answers1

1

Yes, you can inject stuff. See e.g. Insert code into the page context using a content script and How to inject javascript into page, from a Firefox add-on, and run it? or one of the many dupes there likely are.

You can then use whatever communication would be available between the site and a server, e.g. XHR, WebSockets, JSONP.

Please also check the policies of the Chrome Web Store and Mozilla Add-ons site regarding content/code injection and privacy rules. E.g. the Mozilla Add-ons will reject your add-on if you injected remote scripts (meaning code that is not bundled, e.g. originating from e.g. http:) and may also reject your stuff if you track users without prior explicit user consent.

Community
  • 1
  • 1
nmaier
  • 32,336
  • 5
  • 63
  • 78