1

My extension adds a context menu whenever a user selects some text on the page.

Then, using info.selectionText, I use the selected text on a function executed whenever the user selects one of the items from my context menu. (from http://code.google.com/chrome/extensions/contextMenus.html)

So far, all works ok.

Now, I got this cool request from one of the extension users, to execute that same function once per line of the selected text. A user would select, for example, 3 lines of text, and my function would be called 3 times, once per line, with the corresponding line of text.

I haven't been able to split the info.selectionText so far, in order to recognize each line... info.selectionText returns a single line of text, and could not find a way to split it.

Anyone knows if there's a way to do so? is there any "hidden" character to use for the split?

Thanks in advance... in case you're interested, here's the link to the extension

https://chrome.google.com/webstore/detail/aagminaekdpcfimcbhknlgjmpnnnmooo

frenetix
  • 1,199
  • 1
  • 11
  • 19
  • I haven't downloaded your extension so I'm not 100% on what it does. But are the lines/items distinct in some way, like list items, links - is there any any logical way of determining the breaks? Could you perhaps give an example of a few "lines" in your post and that would help to understand a bit more what exactly you are trying to achieve. Thanks. – RidingTheRails Apr 04 '12 at 13:20
  • Hi Richard, I thought that I would look for manual breaks
    or list items
  • . Imagine there's a list of movie titles on a page, one per line (separated with
    or
  • ), and the user selects them... my extension would execute a specific search for each one of the movie titles (that's what my extension does, btw, allows you to search on different search engines).
  • – frenetix Apr 04 '12 at 17:02