-
Notifications
You must be signed in to change notification settings - Fork 1
/
CheckSocialSite.js
45 lines (30 loc) · 1.18 KB
/
CheckSocialSite.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
class CheckSocialSite extends Checker{
static selectAndCheck(node){
// select nodes
this.select(node);
// check selected nodes
this.checkPage(this.selected);
}
// Starts the script
static run() {
// Select the node that will be observed for mutations
const targetNode = document;
// Options for the observer (which mutations to observe)
const config = {childList: true, subtree: true };
// Callback function to execute when mutations are observed
const callback = function(mutationsList, observer) {
// Use traditional 'for loops' for IE 11
for(const mutation of mutationsList) {
for(const addedNode of mutation.addedNodes){
CheckSocialSite.selectAndCheck(addedNode);
}
}
};
// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback);
// Start observing the target node for configured mutations
observer.observe(targetNode, config);
}
}
// get settings and run the script
Settings.getAndRun(CheckSocialSite);