匹配這個答案指定說明如何訪問所有I幀的內容上gmail.com https://stackoverflow.com/a/9439525/222236Chrome擴展:不安全的JavaScript嘗試與URL域名來訪問框架,協議和端口必須
但在mail.google.com它引發此錯誤:
Unsafe JavaScript attempt to access frame with URL https://plus.google.com/u/0/_/... from frame with URL https://mail.google.com/mail/u/0/#inbox. Domains, protocols and ports must match.
我嘗試添加*://plus.google.com/*
到擴展的艙單的比賽,但它並沒有幫助。
更新:檢查用於訪問內容的作品前的網址,但我的邏輯是非常粗略的時刻,因爲它僅檢查谷歌加:
if(-1==iframes[i].src.indexOf('plus.google.com')) {
contentDocument = iframes[i].contentDocument;
if (contentDocument && !contentDocument.rweventsadded73212312) {
// add poller to the new iframe
checkForNewIframe(iframes[i].contentDocument);
}
}
我相信在許多情況下,它可能是遍歷所有子幀的要求,並且從控制流中排除外部域會破壞應用程序的主要功能。所以,在擴展chrome的情況下,我建議用清單中的_content_scripts_「all_frames」:true'聲明替換循環,並使用可選邏輯來合併結果(如果需要)。 – Stan 2015-11-26 14:15:28