-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
37 lines (21 loc) · 1.07 KB
/
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
29
30
31
32
33
34
35
36
37
addEventListener("DOMContentLoaded", (event) => {
getWebsiteURL();
document.getElementById("instagram").onclick = () => chrome.tabs.create({ url: "https://www.instagram.com/kronsuki/" });
document.getElementById("upload").onclick = () => document.getElementById("upload-file-selector").click();
document.getElementById("upload-file-selector").onchange = async (event) => await checkFile(event);
});
function getWebsiteURL() {
chrome.tabs.query({active: true, lastFocusedWindow: true}, tabs => {
let url = tabs[0].url;
const chatrouletteRegex = /^https:\/\/chatroulette\.com\/.*/;
if (!url.match(chatrouletteRegex)) switchTabs('unsupported-tab');
});
}
function switchTabs(tabPaneId) {
const tabPanes = document.getElementById("tabs-container").querySelectorAll(".tab-pane");
tabPanes.forEach( (tabPane) => {
tabPane.classList.remove("active", "show");
});
const selectedTabPane = document.getElementById(tabPaneId);
selectedTabPane.classList.add("active", "show");
}