https://force4u.cocolog-nifty.com/skywalker/2013/08/youtubeyoutubed.html

YouTubeのサムネイル画像サイズとURL

image.png

https://i.ytimg.com/vi/ /maxresdefault.jpg

default.jpg 120x90 mqdefault.jpg 320x180 hqdefault.jpg 480x360 sddefault.jpg 640x480 maxresdefault.jpg 1280x720 と 思っていましたが maxresdefault.jpg に1048x576サイズがある事に今日気がついた

image.png

再生リストからURL取得して置換する

let links = document.querySelectorAll("a#video-title");
for (const i in links) {
  let link = links[i].href;
  let match = "";

  if (!link || typeof link !== "string") {
    continue;
  }

  // 正規表現でパラメータ 'v' の値を取得
  match = link.match(/[?&]v=([^&]+)/);
  let videoId = match ? match[1] : null;

  let imageLink = videoId
    ? "<https://i.ytimg.com/vi/>" + videoId + "/maxresdefault.jpg"
    : null;

  // 結果を表示
  if (imageLink) {
    console.log(imageLink);
  }
}

OR

let links = document.querySelectorAll("a#video-title");
let linksStr = ("\n");
for (const i in links) {
  let link = links[i].href;
  let match = "";

  if (!link || typeof link !== "string") {
    continue;
  }

  // 正規表現でパラメータ 'v' の値を取得
  match = link.match(/[?&]v=([^&]+)/);
  let videoId = match ? match[1] : null;

  let imageLink = videoId
    ? "<https://i.ytimg.com/vi/>" + videoId + "/maxresdefault.jpg"
    : null;

  // 結果を表示
  if (imageLink) {
	  linksStr += imageLink + ("\n");
    //console.log(imageLink);
  }
}

console.log(linksStr);

OR

const divElements = document.querySelectorAll("div");
divElements.forEach((div) => {
  const currentText = div.textContent;
  const replacedText = currentText.replace(/VM7329:3 /g, "");
  div.textContent = replacedText;
});