-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontent.js
More file actions
32 lines (23 loc) · 1.26 KB
/
content.js
File metadata and controls
32 lines (23 loc) · 1.26 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
// contents.js
// Main entry file for the chrome extension "Frozen Mouth"
// Author: cablesalty
console.log("[Frozen Mouth] Extension loaded.");
// Get mute button
const mutebtn = document.querySelector(".ytp-mute-button");
// Check if music is not muted already (if muted skip)
// Really bad looking solution, but localstorage can only store strings so I have to
// parse all the time to get the correct values
if (!JSON.parse(JSON.parse(localStorage.getItem("yt-player-volume")).data).muted) { // Executes when statement is false
console.log("[Frozen Mouth] Sound is enabled! Pressing mute button...");
// Mute by clicking the mute button
mutebtn.click();
// We check again to ensure the muting was successful
if (!JSON.parse(JSON.parse(localStorage.getItem("yt-player-volume")).data).muted) { // Executes when statement is false
// This manually rewrites the localStorage to mute the music
console.log("[Frozen Mouth] Still not muted! Rewriting localStorage and refreshing...");
JSON.parse(JSON.parse(localStorage.getItem("yt-player-volume")).data).muted = true;
location.reload(); // Reload site to apply changes
}
} else {
console.log("[Frozen Mouth] Music already muted, ignoring.");
}