控制台浏览器获取网址

bilibili

const links = document.getElementsByTagName('a');
// 遍历所有链接并查找匹配的网址
for (const link of links) {
  const href = link.href;
  // 使用正则表达式匹配类似的网址
  const urlRegex = /https:\/\/www\.bilibili\.com\/video\/[A-Za-z0-9]+\/?/;
  if (urlRegex.test(href)) {
    console.log("匹配到的网址: " + href);
  }
}

youtube

const links = document.getElementsByTagName('a');

// 遍历所有链接并查找匹配的网址
for (const link of links) {
  const href = link.href;
  // 使用正则表达式匹配 YouTube 视频链接
  const urlRegex = /https:\/\/www\.youtube\.com\/watch\?v=[A-Za-z0-9_-]+/;
  if (urlRegex.test(href)) {
    console.log("匹配到的网址: " + href);
  }
}

dataset

const links = document.getElementsByTagName('a');

// 遍历所有链接并查找匹配 Hugging Face blob 地址
for (const link of links) {
  const href = link.href;
  // 匹配 datasets 仓库 blob 链接
  const urlRegex = /^https:\/\/huggingface\.co\/datasets\/[^/]+\/[^/]+\/blob\/[^/]+\/.+$/;
  if (urlRegex.test(href)) {
    // 替换 blob → resolve
    const realUrl = href.replace("/blob/", "/resolve/");
    console.log("直链: " + realUrl);
  }
}
❤️ 转载文章请注明出处,谢谢!❤️