chrome.runtime.onMessage.addListener( function (rq) { if (rq.action === "content_func_1") { alert("content_func_1"); } } ); if (location_startsWith("www.instagram.com/")) { $("article img").attr("title", "hello"); } // newTab(); // openTab("https://news.bbc.co.uk"); // updateTab("https://news.bbc.co.uk"); //alert("content"); function newTab() { chrome.runtime.sendMessage({ "action": "new_tab" }); } function openTab(url) { chrome.runtime.sendMessage({ "action": "open_tab", "location": url }); } function updateTab(url) { chrome.runtime.sendMessage({ "action": "update_tab", "location": url }); } function location_startsWith(needle) { return startsWith(window.location.href, "http://" + needle) || startsWith(window.location.href, "https://" + needle); } function startsWith(haystack, needle) { return (haystack.toLowerCase().indexOf(needle.toLowerCase()) == 0); }