document.addEventListener('DOMContentLoaded', function () {
    console.log('content script!');
});

function injectCustomJs(jsPath) {
    jsPath = jsPath || 'js/inject.js';
    var temp = document.createElement('script');
    temp.setAttribute('type', 'text/javascript');
    temp.src = chrome.extension.getURL(jsPath);
    temp.onload = function () {
        this.parentNode.removeChild(this);
    };
    document.head.appendChild(temp);
}

window.addEventListener("message", function (e) {
    if (e.data.yunData) {
        console.log(e.data)
        chrome.storage.sync.set(e.data, function () {
            console.log('saved yunData!');
        });
    }
}, false);

injectCustomJs()
