-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
27 lines (25 loc) · 781 Bytes
/
background.js
File metadata and controls
27 lines (25 loc) · 781 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
27
const postLinkRegEx = /^https:\/\/forum.duolingo.com\/comment\/[0-9]+/g;
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (changeInfo.status == "complete" && tab.url.match(postLinkRegEx)) {
console.log("Found page to inject into.");
chrome.tabs.executeScript(
tabId,
{
file: "injected.js"
},
() => {
console.log("Script injected.")
}
);
}
});
chrome.webRequest.onBeforeRequest.addListener(details => {
console.log(details);
chrome.tabs.sendMessage(
details.tabId,
{
identifier: "LOVE-URL",
value: details.url
}
);
}, {urls: ["https://forum-api.duolingo.com/comments/*/love"]});