-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
31 lines (31 loc) · 937 Bytes
/
popup.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
async function getCurrentTab() {
let queryOptions = { active: true, lastFocusedWindow: true };
let [tab] = await chrome.tabs.query(queryOptions);
let url1 = new URL(tab.url)
console.log(url1.hostname)
if (url1.hostname === "jeopardylabs.com"){
let path = url1.pathname
let p = path.split("/")
console.log(p)
if (p[1] === "print"){
go()
}
else if(p[1] === "play" || p[0] === "edit2"){
let new_url = `https://jeopardylabs.com/print/${p[2]}`
chrome.runtime.sendMessage("delay")
chrome.tabs.update({url: new_url}, function (tab) {
console.log(tab)
})
}
}
}
getCurrentTab()
function go(){
chrome.tabs.query({active: true, currentWindow: true}, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, "go")
});
}
function stop() {
window.close()
}
setTimeout(stop, 500)