anonymous YoutubeをDLできるやーつ
No License JavaScript
2020年11月01日
Copy Clone
// コンソールに貼り付けて動画をシークすると…?
(function() {
  const downloaded = {};
  const origin = new URL([...document.head.getElementsByTagName('link')]
    .find(v => v.rel === 'preload' && v.href.indexOf('googlevideo') !== -1).href)
    .origin;
  const title = [...document.body.getElementsByTagName('meta')]
    .find(v => v.name === 'title')
    .content;

  function parseURL(url) {
    if (url.indexOf('videoplayback') === -1) return null;
    const range = url.match(/range=(\d+)-(\d+)/);
    return {
      type: url.indexOf('mime=video') !== -1 ? 'video' : 'audio',
      start: Number(range[1]),
      end: Number(range[2]),
    };
  }

  function stripRange(url) {
    return url.replace(/&range=\d+-\d+/, '');
  }

  function downloadLink(name, link) {
    const a = document.createElement('a');
    a.href = link;
    a.download = name;
    a.textContent = name;

    const player = document.body.getElementsByTagName('ytd-video-primary-info-renderer')[0];
    player.parentNode.insertBefore(document.createElement('br'), player);
    player.parentNode.insertBefore(a, player);
    console.log(a);
  }
  
  var origOpen = XMLHttpRequest.prototype.open;
  XMLHttpRequest.prototype.open = function(method, url) {
      const meta = parseURL(url);
      if (meta !== null) {
        this.addEventListener('load', function() {
          const mime = this.getResponseHeader('Content-Type');
          const match = mime.match(/(video|audio)\/(webm|mp4)/);
          if (match) {
            if (downloaded[meta.type] === undefined) {
              downloaded[meta.type] = true;
              downloadLink(`${title}.${meta.type[0]}.${match[2]}`, stripRange(url));
            }
          }
        });
      }
      origOpen.apply(this, arguments);
  };
})();

// コンソールに貼り付けて動画をシークすると…?
(function() {
  const downloaded = {};
  const origin = new URL([...document.head.getElementsByTagName('link')]
    .find(v => v.rel === 'preload' && v.href.indexOf('googlevideo') !== -1).href)
    .origin;
  const title = [...document.body.getElementsByTagName('meta')]
    .find(v => v.name === 'title')
    .content;

  function parseURL(url) {
    if (url.indexOf('videoplayback') === -1) return null;
    const range = url.match(/range=(\d+)-(\d+)/);
    return {
      type: url.indexOf('mime=video') !== -1 ? 'video' : 'audio',
      start: Number(range[1]),
      end: Number(range[2]),
    };
  }

  function stripRange(url) {
    return url.replace(/&range=\d+-\d+/, '');
  }

  function downloadLink(name, link) {
    const a = document.createElement('a');
    a.href = link;
    a.download = name;
    a.textContent = name;

    const player = document.body.getElementsByTagName('ytd-video-primary-info-renderer')[0];
    player.parentNode.insertBefore(document.createElement('br'), player);
    player.parentNode.insertBefore(a, player);
    console.log(a);
  }
  
  var origOpen = XMLHttpRequest.prototype.open;
  XMLHttpRequest.prototype.open = function(method, url) {
      const meta = parseURL(url);
      if (meta !== null) {
        this.addEventListener('load', function() {
          const mime = this.getResponseHeader('Content-Type');
          const match = mime.match(/(video|audio)\/(webm|mp4)/);
          if (match) {
            if (downloaded[meta.type] === undefined) {
              downloaded[meta.type] = true;
              downloadLink(`${title}.${meta.type[0]}.${match[2]}`, stripRange(url));
            }
          }
        });
      }
      origOpen.apply(this, arguments);
  };
})();

No one still commented. Please first comment.
Output