1

This question is based on a misconception, please see this question instead.

Subject

I am trying to create some context menu options via a Google Chrome extension that allow you to modify the contents of editable fields on certain web pages. My extension works perfectly on StackOverflow, where the DOM is nice and simple, but Youtube has been giving me trouble for some time now.

Problem

Many of the editable fields on Youtube are hidden in Iframes, so if I try to access document.activeElementfrom the top frame, I get the Iframe itself.

I am trying to get around this by injecting chrome.runtime.onMessage() listeners into every page.

Then, I can presumably compare the value returned by info.frameURL in the chrome.contextMenus.onClicked() event listener in the event page, with window.location.href in the content scripts to see if the message is addressing the correct frame or not. (See this question)

The problem is that the value returned by info.frameURL does not seem to be consistent.

For example, if you go to the home page and use the main search box as the test element, sometimes the value is simply, www.youtube.com...., but other times it is plus.google.com..... or apis.google.com..... or accounts.google.com... and I am not sure why this is.

Can someone explain why the value returned by the info.frameUrl would not remain constant each time you click the same frame?

Community
  • 1
  • 1
Luke
  • 5,567
  • 4
  • 37
  • 66
  • it depends whether the user is logged into google account or not (clicking into comment fields). If not, YT will open login form. –  Feb 06 '15 at 17:35
  • 1
    assuming the users login status remains constant between clicks though, this shouldn't matter though, right? Moreover, this is not a factor in the standard search box – Luke Feb 06 '15 at 19:54
  • This sounds like a bug in Chrome. Could you share some sample code for verification? – Rob W Feb 06 '15 at 23:55
  • @RobW I may end up deleteing this question and posting a new one. It turns out its the value of window.location.href that I was speaking of, not frameUrl, however I think I know the problem.... can you confirm that if I send a message to a tab from a content script, it will send it to all frames in that tab? It seems like only one frame is picking it up, even though they all have listeners – Luke Feb 07 '15 at 00:52

0 Answers0