title: How to get a content script to click the LIKE button of a YouTube video?
body: <p>I'm learning how to make Web Extensions and thought it would be fun to start by doing an extensions that likes a YouTube video.</p>
  
  <p>My manifest portion to interact with YouTube is as follows:</p>
  
  <pre><code>  "content_scripts": [
      {
      "run_at": "document_end",
      "matches": ["*://*.youtube.com/*"],
      "js": ["/content_scripts/youtube.js"]
      }
    ],
  </code></pre>
  
  <p>My code is as follows:</p>
  
  <pre><code>    let likeButton = document.querySelector('button[title="I like this"]');
      if (likeButton != null) {
          likeButton.click();
          console.log(likeButton);
          console.log("clicked on like button");
      }
  </code></pre>
  
  <p>In my console I can see the log "clicked on like button". I can also see the button itself, but the "click" part never goes thru, or at least it doesn't actually "like" the video.</p>
  
  <p>If I inspect the loged "likeButton", I can see this:</p>
  
  <pre><code>&lt;button class="yt-uix-button yt-uix-button-size-default yt-uix-button-opacity yt-uix-button-has-icon no-icon-markup like-button-renderer-like-button like-button-renderer-like-button-unclicked  yt-uix-post-anchor yt-uix-tooltip" type="button" onclick=";return false;" title="I like this" aria-label="like this video along with 637 other people" data-post-action="/service_ajax" data-force-position="true" data-orientation="vertical" data-position="bottomright" data-post-data="se=8pH38AERCAASDQoLeHRRQ1FZbEdTem8%3D&amp;amp;itct=CDQQpUEiEwi0iLq78sLTAhUHz5AKHQxkD1wo-B0" data-tooltip-text="I like this" aria-labelledby="yt-uix-tooltip166-arialabel"&gt;
  </code></pre>
  
  <p>If I put that in a variable in the Google Chrome's console, put it on a variable and "click" it with button.click();, it works. But the content script doesn't, and I'm not sure why.</p>