-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
44 lines (40 loc) · 1.14 KB
/
background.js
File metadata and controls
44 lines (40 loc) · 1.14 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
44
chrome.webNavigation.onCommitted.addListener(function (tab) {
if (tab.frameId == 0) {
chrome.tabs.query({ active: true, lastFocusedWindow: true }, (tabs) => {
let url = tabs[0].url;
let parsedUrl = url
.replace("https://", "")
.replace("http://", "")
.replace("www.", ""); // linkedin.com //linkedin.com/pub/dir/+/+?trk=guest_homepage-basic_guest_nav_menu_people
let domain = parsedUrl
.slice(
0,
parsedUrl.indexOf("/") == -1
? parsedUrl.length
: parsedUrl.indexOf("/")
)
.slice(
0,
parsedUrl.indexOf("?") == -1
? parsedUrl.length
: parsedUrl.indexOf("?")
);
try {
if (domain.length < 1 || domain === null || domain === undefined) {
return;
} else if (domain == "linkedin.com") {
runLinkedinScript();
return;
}
} catch (err) {
throw err;
}
});
}
});
function runLinkedinScript() {
chrome.tabs.executeScript({
file: "linkedin.js",
});
return true;
}