-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcontent.js
More file actions
60 lines (54 loc) · 1.75 KB
/
content.js
File metadata and controls
60 lines (54 loc) · 1.75 KB
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
keys = ["slide", "market", "present", "presentation", "product", "but", "attendance", "name"];
var mutationObserver = new MutationObserver(function(mutations) {
mutations.forEach(mutation => {
if (mutation.target.nodeName=="SPAN"){
mutation.addedNodes.forEach(addedNode => {
if (addedNode.nodeName=="SPAN"){
let currentText = addedNode.innerText.toLowerCase();
console.log("added: ", currentText);
keys.forEach(key => {
if (currentText.includes(key)) {
console.log("found");
chrome.runtime.sendMessage('', {
type: 'notification',
options: {
title: key,
message: currentText,
iconUrl: '/icon.png',
type: 'basic'
}
});
}
});
}
})
mutation.removedNodes.forEach(removedNode => {
if (removedNode.nodeName=="SPAN"){
console.log("removed: ", removedNode.innerText);
}
})
}
})
});
function addObserverIfDesiredNodeAvailable() {
console.log("checking to add")
var composeBox = document.querySelector(".a4cQT");
if (!composeBox) {
window.setTimeout(addObserverIfDesiredNodeAvailable,500);
return;
}
var config = {childList: true};
console.log("added")
document.querySelectorAll(".cS7aqe").forEach(element => {
console.log(element);
});
mutationObserver.observe(document.querySelector(".a4cQT"), {
attributes: true,
characterData: true,
childList: true,
subtree: true,
attributeOldValue: true,
characterDataOldValue: true
});
}
addObserverIfDesiredNodeAvailable();