0

i'm developing chrome extension. I want to add button to youtube. But button is not showing. (It only appears for a very short time while the page is loading, then disappears immediately.)

Content.js

let btn = document.createElement("button");
btn.innerHTML = "Music Button";
btn.id = "btn-music";
btn.style.zIndex = "10";
document.body.appendChild(btn);
document.getElementById("title").insertBefore(btn, document.getElementById("title").children[0]);
Ekin
  • 107
  • 1
  • 9
  • See [How to detect page navigation on YouTube and modify its appearance seamlessly?](https://stackoverflow.com/a/34100952) – wOxxOm Dec 14 '22 at 16:09
  • It didn't work, can you give an example? – Ekin Dec 14 '22 at 16:33
  • The answer I've linked shows such an example. You can adapt it to your needs (e.g. maybe use `yt-navigate-finish` event instead) and use devtools to debug the problems. – wOxxOm Dec 14 '22 at 16:53
  • Error: Uncaught ReferenceError: process is not defined – Ekin Dec 14 '22 at 16:58
  • error for document.addEventListener('yt-navigate-start', process); – Ekin Dec 14 '22 at 16:59
  • Read the answer completely, you'll see `function process` there. – wOxxOm Dec 14 '22 at 18:10
  • I tried everything but it didn't work. Can you give an example? It could be an example of adding any button to the youtube page. – Ekin Dec 15 '22 at 10:23

0 Answers0