-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbackground.js
More file actions
112 lines (104 loc) · 2.95 KB
/
Copy pathbackground.js
File metadata and controls
112 lines (104 loc) · 2.95 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
chrome.tabs.onUpdated.addListener((tabId, _, tab) => {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
let activeTab = tabs[0];
console.log(activeTab);
// 1. Youtube funtions
if (activeTab.url && activeTab.url.includes("youtube.com/watch")) {
const queryParameters = activeTab.url.split("?")[1];
const urlParameters = new URLSearchParams(queryParameters);
console.log(activeTab.url);
chrome.tabs.sendMessage(
activeTab.id,
{
type: "NEW_YOUTUBE",
videoId: urlParameters.get("v"),
videoLink: activeTab.url,
url: tab.url,
},
(res) => {
console.log(res);
}
);
}
// For profile visit
if(activeTab.url && activeTab.url.includes('youtube.com/@')){
chrome.tabs.sendMessage(
activeTab.id,
{
type: "NEW_YOUTUBE_PROFILE",
videoId: "@"+activeTab.url.split("/")[0],
videoLink: activeTab.url,
url: tab.url,
},
(res) => {
console.log(res);
}
)
}
if(tab.url && tab.url.includes('linkedin.com/in/')){
console.log('sending to Profile: ', tab.url);
chrome.tabs.sendMessage(tabId,{
type: 'Profile',
name: 'Profile',
url: tab.url,
})
}
else if(tab.url && tab.url.includes('linkedin.com/groups/')){
console.log('sending to Profile: ', tab.url);
chrome.tabs.sendMessage(tabId,{
type: 'Profile',
name: 'Profile',
url: tab.url,
})
}
else if(tab.url && tab.url.includes('linkedin.com/company')){
console.log('sending to Profile: ', tab.url);
chrome.tabs.sendMessage(tabId,{
type: 'Profile',
name: 'Profile',
url: tab.url,
})
}
if (activeTab.url && (/(https:\/\/twitter.com\/(?![a-zA-Z0-9_]+\/)([a-zA-Z0-9_]+))/).test(activeTab.url)) {
const queryParameters = activeTab.url;
const urlParameters = new URLSearchParams(queryParameters);
console.log(activeTab.url);
console.log("Tweet")
chrome.tabs.sendMessage(
activeTab.id,
{
type: "NEW_TWITTER_PROFILE",
videoId: urlParameters.get("v"),
videoLink: activeTab.url,
url: tab.url,
},
(res) => {
console.log(res);
}
);
}
//Twitter Post
if(tab.url && tab.url.includes('/status/')){
console.log('sending to tweet: ', tab.url)
chrome.tabs.sendMessage(tabId, {
type: "TWEET",
name: 'tweet',
tweetLink: tab.url,
url: tab.url
})
}
//LinkedIn Feed
if(tab.url && tab.url.includes('linkedin.com/feed/')){
console.log('sending to LinkedIn: ', tab.url)
chrome.tabs.sendMessage(tabId,{
type: 'Job_Post',
name: 'LinkedIn',
url: tab.url
})
}
}
//For profile
);
// 2. Twitter Functions
// 3. LinkedIn functions
});