Hi, I am trying to code a safari extension similar to Bubble Translate for Chrome.
when you click a button on the toolbar, it automatically translates the text currently selected to the language of your choice using the Google language API.
I use the following injected script to get the highlighted text and display the result (as an alert for the time being): http://pastebin.com/bYVuQAmp
I use the following global script to call the injected script if neccessary: hxxp://pastebin.com/VHaAKM5a
The problem I have is the following:
The script does not just get injected into the main page but also into ads and similar stuff that is embedded into the page. Due to that, the selected text gets translated multiple times because all the embedded scripts in one page respond to the message.
How can I make sure that the script is injected only into the right page or only the right page responds?
Thank you,
Philipp