Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

157
Vistas
Recording clicks and keystrokes to a csv

I'm attempting to make a Chrome extension that records the number of clicks, keystrokes, and time spent within a certain period of time on a given website (e.g., 45 clicks, 296 keystrokes, and 129 minutes spent on Facebook within one week). I've never coded before and the course I'm writing this code for did not cover Chrome extensions.

So far, I've figured out how to make a simple message appear in the console log when I click the webpage (code given below), but that's about it. How would I export the number of clicks to a .csv?

manifest.json

    "name": "Social Media Consumption Tracker",
    "version": "1.0",
    "manifest_version": 2,
    "content_scripts": [
        {
            "matches": ["https://www.facebook.com/*",
            "http://www.facebook.com/*"],
            "js": ["content.js"]
        }
    ],
  "permissions": ["tabs"]
}

content.js

document.addEventListener("click", e=> {
    console.log("Hey there")
})

Thank you in advance for your help.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I would suggest sending what you have been recording (the clicks and actions) to the background.js file and manipulating it you can do that using chrome.runtime.send messages and chrome.runtime.onMessage` Then after that, generate a download link inside your extension popup to allow the user to download the CSV (you can generate the file the background file)

about 4 years ago · Juan Pablo Isaza Denunciar

0

I think what you need for tracking clicks is the chrome.storage api and Maps

  1. Add your eventListeners for the events you want to track.
  2. When one event you track is fired:

var currentDomain = new URL(location.href).hostname;

document.addEventListener("click", e=> {
    increaseEventCounter("click");
})

function increaseEventCounter(event) {

  chrome.storage.local.get(['youNameIt'],(result) => {
      let youNameIt = result.youNameIt;
      let currentWebsiteEventCounter = youNameIt.get(currentDomain).get(event);
      youNameIt.get(currentDomain).set(event, currentWebsiteEventCounter + 1);

      chrome.storage.local.set({'youNameIt': youNameIt});
  }
  
}

I think storage won´t keep the type of youNameIt, so you need to find a way to cast it again to Map<String,Map<String,Int>>.

  1. Another function which adds new Websites to youNameIt with the counter of every Event you track set to 0.

  2. Search stackOverflow on how to track timeSpend on different Websites, i´m sure there are already answers for that.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda