-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
26 lines (24 loc) · 801 Bytes
/
Copy pathcontent.js
File metadata and controls
26 lines (24 loc) · 801 Bytes
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
// Listen for messages
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
// Check if on correct page
switch (msg.page) {
case "github":
let repoElement = document.getElementById("repo-content-pjax-container");
if (repoElement) {
sendResponse({ tab: msg.tab, found: true });
}
break;
case "devops":
let repoLink = document.getElementsByClassName(
"repos-file-explorer-header-repo-link text-ellipsis"
)[0];
if (!repoLink) {
sendResponse({ tab: msg.tab, found: false });
}
let version = new URL(repoLink.href).searchParams.get("version");
sendResponse({ tab: msg.tab, found: true, version: version });
break;
}
sendResponse({ tab: msg.tab, found: false });
return true;
});