-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
28 lines (25 loc) · 873 Bytes
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// chrome.tabs.onUpdated.addListener((tabId, tab) => {
// if (tab.url && tab.url.includes("youtube.com/watch")) {
// const queryParameters = tab.url.split("?")[1];
// const urlParameters = new URLSearchParams(queryParameters);
// chrome.tabs.sendMessage(tabId, {
// type: "NEW",
// videoId: urlParameters.get("v"),
// });
// }
// });
chrome.runtime.onInstalled.addListener(()=>{
console.log("crx installed");
chrome.runtime.onMessage.addListener((message,sender,sendResponse)=>{
if(message.action==="newtab")
{
chrome.tabs.create({url:message.url});
}
if(message.action==="getlocalstorage" && message.from==="popup")
{
chrome.runtime.sendMessage({action:"getlocalstorage",data:message.data,from:"background"},(response)=>{
sendResponse(response);
})
}
})
});