-
Notifications
You must be signed in to change notification settings - Fork 0
/
hideVideos.js
33 lines (33 loc) · 1.04 KB
/
hideVideos.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
document.addEventListener("DOMContentLoaded", function () {
var hideVideos = document.getElementById("hideVideos");
chrome.storage.sync.get("hide", function (data) {
hideVideos.checked = data.hide;
});
hideVideos.onchange = function (element) {
let value = this.checked;
chrome.storage.sync.set({ hide: value }, function () {
console.log("The value is" + value);
});
if (value) {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
chrome.tabs.sendMessage(
tabs[0].id,
{ command: "hideVids", hide: value }, // message to be sent
function (response) {
console.log(response.result);
}
);
});
} else {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
chrome.tabs.sendMessage(
tabs[0].id,
{ command: "showVids", hide: value }, // message to be sent
function (response) {
console.log(response.result);
}
);
});
}
};
});