-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
35 lines (30 loc) · 991 Bytes
/
content.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
let options, like;
chrome.runtime.onMessage.addListener(
function(message) {
options = message;
like = new MaterialLiker(options);
// store options in content script
chrome.storage.local.set(options);
like.init();
}
);
chrome.storage.local.get(options, (data) => {
options = data;
});
// Reloads the MaterialLiker whenever the user goes to another Video..
let old_url = '';
let mutationObserver = new MutationObserver( mutations => {
mutations.forEach( mutation => {
if (location.href != old_url) {
// URL Changed
old_url = location.href;
setTimeout(()=>{
if(!options)
options = {disabled: true}
like = new MaterialLiker(options);
like.init();
},3000);
}
});
});
mutationObserver.observe(document.documentElement, {childList: true, subtree: true});