Question

This might be a broad question but I couldn't find a definite explanation on how to do this (maybe I am just not searching well enough).

I am writing a Chrome extension, that writes data I collect from a site about how many times the site has been visited (how many times the site has been clicked) and update to a database. The count should be shown before the site is opened when it is searched in Google.

The problem is that I really have no idea how to do this or where to start. It's my first Chrome extension, and on top of that it is the first time I ever use a database. A lot of firsts in this project :).

After googling, I found out that I probably have no idea how to use only javascript for writing the data into the database. But other than that, I am completely stumped and don't really know where to begin.

Any tips please?

Again, sorry if my question is too broad. Maybe this topic will help a future newbies (like me) get up to speed with this.

Thanks in advance.

Was it helpful?

Solution

As told in comment, you should start by learning javascript and the basics of chrome extensions before starting a project like this. (Get Started and API reference)

I assume the principal question is: How to send data from the extension back to your server?


Short Version

A solution is to use AJAX requests from the background page when you need to send data to the server.

Detailed Version

  1. Get the data you need from content scripts when the user visits a page.
  2. Send this data back to your background page through message passing.
  3. From your backgroud page Use pure Javascript or the Jquery framework to send the AJAX request. There are lots of question on this subject on stackoverflow.
  4. Do not forget to set the correct permissions in your manifest.json file (https://developer.chrome.com/extensions/xhr).
  5. Build a page (PHP, Java, etc.) on your server to recieve the POST data.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top