I am trying to learn to develop chrome extensions. I am using YouTube for experimenting. I have a small content_script that just creates a div inside the YouTube video player.
The is created but it breaks the whole page UI. As you can see in the picture, the top bar is gone. The video title, subscribe button and all the other stuff like thumbs up, thumbs down etc are not being rendered properly. Why is this happening? How do I write my extension sp that it does not break the UI?
CODE
{
"manifest_version": 2,
"name": "name",
"version": "0.1",
"author": "author",
"description": "",
"content_scripts": [{
"matches": [
"<all_urls>"
],
"js": [
"content.js"
],
"css": ["style.css"]
}],
}
content.js
window.addEventListener('load', function() {
let holder = document.getElementById("player-container").querySelector("#container").querySelector("#movie_player");
console.log(holder.offsetHeight)
let divContainer = document.createElement("div");
holder.appendChild(divContainer);
divContainer.style.height = "80%";
divContainer.id = "container";
});
css
#container {
display: grid;
width: 300px;
position: absolute;
bottom: 0;
right: 0;
z-index: 9999;
/* background-color: rgb(0, 0, 0); */
}