I have a extension that is doing all kind of stuff with any given website. Everything worked well before i added popup window in purpose to use it as some kind of UI for the extension. After i have found it impossible to get my code run anywhere outside of that popup..
This sample is from my previous unsuccessful try:
HTML is just a start (starts initSession function) and stop button with access to content.js. I'am looking for solution (if there is a one) where i don't have to inject the actual page and could handle this with messages somehow..
content.js:
function initSession() {
window.close(); //popup..
chrome.runtime.sendMessage({
message: 'popup_closed'
}, function(response) {
var response = response.message;
if(response === "ready_to_record")
startRecording();
});
}
function startRecording(){
createListeners();
}
//background.js
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse, tab) {
if (request.message == "popup_closed")
sendResponse({message: "ready_to_record"});
});