如何将选中的元素从devTools页面发送到chrome侧边栏页面
How to I send selected element from devTools page to chrome sidebar page
我正在开发一个chrome devTools扩展。基本上我有一个侧边栏窗格添加到元素面板。 devtools.js
chrome.devtools.panels.elements.createSidebarPane("ChromeTrast", function(sidebar) {
sidebar.setPage('devTools/chromeTrastDevTools.html');
}
chrometrastDevTools.html
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
</head>
<body>
<p id="devTool-report"></p>
<script src="../resources/jquery.js"></script>
<script src="../resources/mustache.js"></script>
<script src="../element/chromeTrastElement.js"></script>
<script src="../element/RGB.js"></script>
<script src="chromeTrastSidebar.js"></script>
</body>
</html>
在devtools.js中,我需要获得选定的元素($0)并将其发送到chrometrastSidebar.js。
基本上,我希望从devtools.js> chrometrastSidebar.js传递数据
chrometrastSidebar.js是来自侧边栏html页面的源文件。
我尝试使用chrome.devtools.inspectedWindow.eval(),但它没有工作。
我做了一些研究,但所有的消息从contentscript到背景页。
感谢您的帮助
You would preferably use to get and receive as below accordingly.
chrome.extension.sendMessage({greeting: "hello"}, function(response) {
console.log(response.farewell);
});
chrome.extension.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.greeting == "hello") sendResponse({farewell: JSON.stringify(sender)});
});
相关文章:
- 当侧边栏很长时,滚动/固定侧边栏会被切断
- 创建带有侧边栏的谷歌地图
- 如何在显示侧边栏时禁用背景,单击除侧边栏之外的任何位置都会关闭侧边栏
- 在页脚处停止固定侧边栏-防止重叠
- 如何将javascript添加到Wordpress侧边栏中
- 如何正确地将数据发送到打开的Firefox侧边栏
- 如何制作侧边栏以增加其完整长度
- 固定位置侧边栏不滚动-设置内容的高度
- Firefox插件SDK:在侧边栏和主脚本之间通信对象
- 在上下文菜单项单击上显示侧边栏/弹出窗口的最佳方法是什么
- 如何将数组(Google应用程序脚本)返回到HTML侧边栏
- 切换传单侧边栏 V2
- 粘性侧边栏停止在页脚上方 30px
- 使用什么js函数来切换侧边栏
- Chrome扩展等同于Firefox附加侧边栏
- Chrome扩展程序将侧边栏注入页面
- 如何将选中的元素从devTools页面发送到chrome侧边栏页面
- 是否建议开发Chrome侧边栏扩展
- 重新加载Chrome DevTools扩展侧边栏在页面更改
- 当点击时,在注入的侧边栏chrome扩展中的字段内添加网页上的所选文本