问题描述
在我使用的popup.js中
function click(e) {
chrome.tabs.query({ currentwindow: true,active: true },function (tabs) {
let activeTab = tabs[0];
chrome.tabs.sendMessage(activeTab.id,{ "timetoSeek": e.target.id })
})
}
但是我的contentScript已注入到DOM 中,因此当我尝试获取消息时:
chrome.runtime.onMessage.addListener(function(req,send){
//trying to get netflix object in order to seek to time
netflix.appContext.state.playerApp.getAPI().videoPlayer
// netflix is undefinded
})
chrome.runtime.onMessage在注入的脚本中未定义。
(我正在开发chrome扩展程序,该扩展程序使用netflix api。因此我必须从内容脚本中注入脚本)
预先感谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)