내 콘텐츠 스크립트가 내 백그라운드 페이지와 통신하는 데 문제가 있습니다. 압축을 푼 확장 프로그램을 실행 중입니다. 내 콘텐츠 스크립트 send.js
에서 나는 선을크롬 확장 background.html 콘솔에 로그인하지 않음
chrome.extension.sendRequest({message: "hey"}, function(response){});
을 가지고처럼 내 background.html
보이는 : 나는 Port error: Could not establish connection
오류가 계속
<script>
/* the coffeescript way, but I also tried without the
* coffeescript wrappers and got the same errors. */
(function() {
var dispatchRequest;
dispatchRequest = function(request, sender, sendResponse) {
console.log("request dispatch called");
}
chrome.extension.onRequest.addListener(dispatchRequest);
}).call(this);
</script>
.
그냥 변경 오류를 발견하려고 노력하는 내 나는 다음 페이지를 다시로드와 크롬 콘솔을 확인하지만 출력이 없었다 background.html
<script>
console.log("Background html is running!");
</script>
에.
은 여기 내 manifest.json
(약칭 함) 다음 background.html
실행 얻거나 어떻게와 통신 할 수 내 콘텐츠 스크립트를 얻을하는 방법을 알아 내기 위해 내가 손해를보고있어이 시점에서
{
"background-page": "background.html",
"content_scripts": [{
"all_frames": true ,
"css": [ "style.css" ] ,
"js": [ "send.js" ] ,
"matches": [ "http://mail.google.com/*" ,
"https://mail.google.com/*" ]
}],
"permissions": [ "tabs", "http://*/", "https://*/", "cookies" ]
}
.
멋진 장소입니다. 나는 지금 어리 석다. –
이 방법은 오래되었으므로 더 새로운 방법은''background ": {"page ":"background.html "}' – ripper234