title: Prevent users from getting url from embedded YouTube video/disable clipboard
body: <p>I have a website where I embed a YouTube video in an iframe. My problem is that I don't want the user to get the videoID or the link to the video (atleast without opening the console because that's propably impossible).</p>
  
  <p>I already managed to disable the YouTube logo on which one can click at to open the video in a new tab. But there is the context menu if you rightclick on the video where one can copy the video url to his clipboard and so on.</p>
  
  <p>After a lot of research if found out that there is no possibility to disable the context menu somehow because that would be cross-site-scripting.</p>
  
  <p>Another possible method would be to constantly check the users clipboard if there is some string in it containing the videoID. This won't work aswell (except in IE i guess) because there are some restrictions to access the clipboard so i can't find out what the user saves in it (even with flash).</p>
  
  <p>It would also be enough to just check if the clipboard content changed to detect that the user maybe tried to get the videoURL (it's no problem if he finds out the video url as long as I know about it).</p>
  
  <p>Disabling the clipboard at all or spamming it with something else seems impossible too.</p>
  
  <p>I hope there is a solution to my problem, thanks.</p>
  
  <p>Edit:</p>
  
  <p>this is the used HTML including some scripts (aswell as some that are not working)</p>
  
  <pre><code>&lt;script&gt;
  
      var tag = document.createElement('script');
      tag.src = "https://www.youtube.com/iframe_api";
      var firstScriptTag = document.getElementsByTagName('script')[0];
      firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  
      var player;
      function onYouTubeIframeAPIReady() {
          player = new YT.Player('player', {
              events: {
                  'onReady': onPlayerReady,
                  'onStateChange': onPlayerStateChange
              }
          });
      }
  
      function onPlayerReady(event) {
          console.log("READY");
  
          event.target.playVideo();
      }
  
      function onPlayerStateChange() {
          console.log("STATE CHANGED");
      }
  
  &lt;/script&gt;
  
  &lt;body&gt;
      &lt;div class="all"&gt;
  
          &lt;?php
              include "parts/header.php";
          ?&gt;
  
          &lt;div class="player-bg"&gt;
              &lt;div class="player"&gt;
                  &lt;iframe
                      id="player"
                      width="640"
                      height="390"
                      frameborder="0"
                      sandbox="allow-forms allow-scripts allow-pointer-lock allow-same-origin allow-top-navigation"
                      src="&lt;?=$embedURL?&gt;"&gt;
                  &lt;/iframe&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
  
          &lt;div class="usercontrols-container"&gt;
              &lt;form id="form" method="post" action="./views.php" autocomplete="off"&gt;
                  &lt;input class="textfield" type="text" min="0" name="guessViews"/&gt;
                  &lt;a class="button" href="#" onclick="document.getElementById('form').submit();"&gt;Guess&lt;/a&gt;
              &lt;/form&gt;
          &lt;/div&gt;
  
      &lt;/div&gt;
  &lt;/body&gt;
  
  &lt;script&gt;
      function copy() {
          console.log("copy detected 2");
      }
  
      document.addEventListener("copy", function() {
          console.log("copy detected 1");
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Blakk</p>