-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage.js
37 lines (35 loc) · 850 Bytes
/
page.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
const windowLocation = "" + window.location;
//Add every link that is clicked on as a new node
window.addEventListener("click", (e) => {
if (!e.target.closest("a")) {
return;
}
const linkCLicked = e.target.closest("a").href;
if (e.ctrlKey || e.metaKey) {
browser.runtime.sendMessage({
cmd: "click",
source: windowLocation,
target: linkCLicked,
type: "new tab",
});
} else {
browser.runtime.sendMessage({
cmd: "click",
source: windowLocation,
target: linkCLicked,
type: "same tab",
});
}
});
window.addEventListener("auxclick", (e) => {
if (!e.target.closest("a")) {
return;
}
const linkCLicked = e.target.closest("a").href;
browser.runtime.sendMessage({
cmd: "click",
source: windowLocation,
target: linkCLicked,
type: "new tab",
});
});