-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
43 lines (40 loc) · 1.25 KB
/
background.js
File metadata and controls
43 lines (40 loc) · 1.25 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//tried sending message from popup.js to background.js
// try{
// chrome.runtime.onMessage.addListener( async function(request,sender,sendResponse)
// {
// console.log("incoming message from popup.js detected!");
// if( request.greeting === "GetURL" )
// {
// console.log("got the message");
// var tabURL = "Not set yet";
// chrome.tabs.query({active:true},function(tabs){
// if(tabs.length === 0) {
// sendResponse({});
// return;
// }
// tabURL = tabs[0].url;
// sendResponse( {navURL:tabURL} );
// });
// }
// });
// }catch(e){
// console.log(e);
// }
// run the following if DOM updates
// also only run on linkedin
try{
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if(changeInfo.status == 'complete' && tab.url && tab.url.includes("linkedin.com/")){
chrome.scripting.executeScript({
files: ['contentBack.js'],
target: {tabId: tab.id}
});
chrome.scripting.insertCSS({
files: ['contentBack.css'],
target: {tabId: tab.id}
});
}
});
}catch(e){
console.log(e);
}