2

I have a big problem reading some pages on the internet. So I'm trying to make an Extension to ease my problem.

I just started, still learning everything I can do with the manifest.json.

BUt I'd like to know how may I get the element clicked by the user.

Like the extension whatFont, when you click on it's icon, you just have to hover the elements to know which font that's using... To do so, you have to read the element ( I guess).

How may I get the clicked element ? Just some tips/terms to search/anything... Thanks!

PlayHardGoPro
  • 2,791
  • 10
  • 51
  • 90
  • 1
    What about `document.getElementsByTagName('body')[0].addEventListener('click', function(e) { alert(e.target); });` ? In this case, `e.target` is the clicked element from body's tag. –  Aug 31 '16 at 20:23
  • 1
    @nicematt Do I just create a `file.js` ? How may I link it to the `manifest` ? – PlayHardGoPro Aug 31 '16 at 20:24
  • 1
    I never made a add-on, but you can check this link https://robots.thoughtbot.com/how-to-make-a-chrome-extension, it has a example on how to include *.js. –  Aug 31 '16 at 20:26
  • 3
    See also [How to access the webpage DOM rather than the extension page DOM?](http://stackoverflow.com/q/4532236) – wOxxOm Aug 31 '16 at 20:40
  • 1
    See also [Page Redder sample extension](https://developer.chrome.com/extensions/samples#search:redder) that showcases the bare minimum with a noninvasive modern approach ([`"activeTab"` permission](https://developer.chrome.com/extensions/activeTab)). – wOxxOm Aug 31 '16 at 20:46
  • Thanks, guys ! I understand a lot more about the types of files and how to link them. What I don't know yet is: Once I click my extension's icon, how may I make it wait for the user to click on a div or something... – PlayHardGoPro Aug 31 '16 at 21:32
  • 1
    @PlayHardGoPro, I would suggest that you read the [Chrome extension architecture overview](https://developer.chrome.com/extensions/overview#arch). It has overall background information which should help your understanding of how things are generally done/organized. – Makyen Aug 31 '16 at 21:54
  • Guys. I kind made it :D I can edit the Body font size. The problem is: Sometimes editing the body font size, won't change the size of the letters you're reading, right ? How may I select the div ? I'm reading everything you guys sent me, but Can't find how to specify the div – PlayHardGoPro Aug 31 '16 at 22:31
  • Now you're stuck with basic JavaScript stuff: modifying DOM. This is not something that can be answered in a couple of sentences. You need to study a tutorial or read a book on that. – wOxxOm Sep 01 '16 at 06:38

0 Answers0