-1

I want to add a button red highlighted place on YouTube. But it doesn't work.

manifest.json

{
  "name": "Example",
  "version": "0.0",
  "manifest_version": 2,
  "content_scripts": [
    {
      "js": ["content.js"],
      "matches": ["<all_urls>"],
      "css": ["style.css"]
    }],
  "browser_action": {
    "default_popup": "addon_menu.html",
    "default_title": "Example"
  }
} 

content.js

console.log("Example is on!");


var  sttndiv = document.createElement("div");
var sttnbtn = document.createElement("button");
sttndiv.appendChild(sttnbtn);
document.getElementById("buttons").getElementsByClassName("yt-live-chat-message-input-renderer")[0].appendChild(sttndiv)[0];

Uncaught TypeError: Cannot read properties of undefined (reading 'appendChild')

enter image description here

Rubén
  • 34,714
  • 9
  • 70
  • 166
Hangear
  • 9
  • 3

1 Answers1

-1

By the error and common sense, you can see that sttndiv is undefined, this could be because there's a double space in front of it.

MadMisty
  • 1
  • 4