0

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"});

});
Lukasz Koziara
  • 4,078
  • 4
  • 29
  • 40
  • 1
    startRecording function creates eventlisteners always to popup.html.. or in this particular case it doesnt create anything anywhere as popup is already closed.. – Mika Lindh Jun 07 '18 at 18:27
  • Possible duplicate of [How to access the webpage DOM rather than the extension page DOM?](https://stackoverflow.com/questions/4532236/how-to-access-the-webpage-dom-rather-than-the-extension-page-dom) – wOxxOm Jun 07 '18 at 18:43

0 Answers0