hepengwei / chrome-extension-basic-demo Goto Github PK
View Code? Open in Web Editor NEW🌈 一款带你十分钟入门Chrome插件开发的基础demo,完整案例展示。
🌈 一款带你十分钟入门Chrome插件开发的基础demo,完整案例展示。
你好,我根据你的这个项目稍微修改了一下popup和contnet的代码,想实现之间的通信,但遇上了这样的问题,可以麻烦你花费一些时间帮忙看看吗
以下是我的代码:
popup.js
chrome.tabs.query({ active: true, currentWindow: true }, tabs => {
// Send a request to the content script.
console.log("tabs: ", tabs)
if (tabs.length != 0) {
chrome.tabs.sendMessage(tabs[0].id, { message: "sendurl" }, function (response) {
console.log("接收content返回: ", response);
});
}
});
content.js
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if( request.message === "sendurl" ) {
sendResponse({url: "xxx"});
}
}
);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.