I'm trying to write Firefox add-on that will follow users activity for chosen web links at some webpage. Because I'm not so familiar with web development, I would appreciate your suggestions and directions how to finish this task.
I already made one simple Firefox add-on, but yet don't have idea how to mark wanted links and how to make 开发者_开发百科counter for clicks at that (chosen) links. Probably I need to add function in JavaScript file that will be placed in content folder and called within html file, but I need your help how to locate wondered web link? I.e. do I need to locate it using Element ID (and how to do it) or there is some other way?
Also, if somebody knows similar add-on that is already written, that would be perfect!
Thanks in advance!
Nemanja
Essentially, you just need an event listener listening for the click
event. You could call content.document.addEventListener('click', myListener, true);
every time a page loads, or you could just call gBrowser.addEventListener('click', myListener, true);
when the whole program starts up. Either way, myListener
will be passed the click event as an argument, so then you can do something like:
function myListener(event) {
if (event.target.href && event.target.href === 'some.url.com')
updateCounter();
}
I hope this makes sense.
精彩评论