import {
    appendPopupPage,
    tiggerInjectPopupPage
} from "@/logic/content/twitter.js";

window.onload = () => {
    appendPopupPage();
    chrome.runtime.sendMessage({ 
        actionType: "CONTENT_WINDOW_LOADED_SET_POPUP_PAGE", 
        data: { } 
    }, () => { });
};

chrome.runtime.sendMessage({ 
    actionType: "CONTENT_SET_POPUP_CONFIG", 
    data: {
        popup: 'popup.html'
    } 
}, () => { });

chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
    sendResponse('')
    switch (req.actionType) {
        case 'BACK_PING':
            console.log('BACK_PING')
            chrome.runtime.sendMessage({ actionType: "CONTENT_PONG", data: '1' }, (res) => { console.log(res) })
            break
        case 'BG_INJECT_EXTENSION_POPUP':
            tiggerInjectPopupPage();
            break
    }
})
