-
Notifications
You must be signed in to change notification settings - Fork 2
/
dist.js
71 lines (64 loc) · 2.12 KB
/
dist.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
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
function newTab() {
chrome.tabs.create({active:true});
}
function removeTab() {
chrome.tabs.query({active:true,currentWindow:true},(tab)=>{
chrome.tabs.remove([tab[0].id]);
})
}
function TabForward() {
chrome.tabs.query({currentWindow:true},(tab)=>{
console.log(tab);
chrome.tabs.query({currentWindow:true,active:true},(tab2)=>{
console.log("current tab = ");
console.log(tab2);
let pos =0;
while(pos<tab.length && tab[pos].id!=tab2[0].id){
pos++;
}
pos++;
pos = pos%tab.length;
chrome.tabs.highlight({tabs:[pos]});
});
});
}
function scrollUp() {
console.log("going up");
// chrome.tabs.query({active:true,currentWindow:true},(tab) => {
// chrome.tabs.executeScript(tab[0].id,{
// code: 'window.scrollBy(0, -500);'
// });
// });
window.scrollBy(0,-500);
}
function scrollDown() {
console.log("going down");
window.scrollBy(0,500);
}
function TabBackward() {
chrome.tabs.query({currentWindow:true},(tab)=>{
console.log(tab);
chrome.tabs.query({currentWindow:true,active:true},(tab2)=>{
console.log("current tab = ");
console.log(tab2);
let pos =0;
while(pos<tab.length && tab[pos].id!=tab2[0].id){
pos++;
}
pos--;
pos = pos+tab.length;
pos = pos%tab.length;
chrome.tabs.highlight({tabs:[pos]});
});
});
}
document.getElementById("scan").addEventListener("click",()=>{
console.log("HEy");
chrome.tabs.create({url:"index.html",active:false},()=>{});
});
document.getElementById("go_f").addEventListener("click",TabForward);
document.getElementById("go_b").addEventListener("click",TabBackward);
document.getElementById("newTab").addEventListener("click",newTab);
document.getElementById("removeTab").addEventListener("click",removeTab);
document.getElementById("scrollUp").addEventListener("click",scrollUp);
document.getElementById("scrollDown").addEventListener("click",scrollDown);