o3-mini· OpenAI
LMArena Human Preference 140K
你看下边的js脚本,帮我加上一个提取目标媒体链接的功能,需要提取的html目标链接结构: [code] js脚本结构: [code] 不要改变原先的结构
- User
你看下边的js脚本,帮我加上一个提取目标媒体链接的功能,需要提取的html目标链接结构:
html<meta name="og:video" content="https://sns-video-hw.xhscdn.com/stream/79/110/259/01e8527a8b49da4f0103700397823735ee_259.mp4">js脚本结构:// ==UserScript== // @name media-tracker // @namespace http://tampermonkey.net/ // @version 2025-05-23 // @description try to take over the world! // @author You // @match http://*/* // @grant none // ==/UserScript== (function() { 'use strict'; // Your code here... // Find video and audio elements document.querySelectorAll('video source, audio source').forEach(source => { console.log('Media source URL:', source.src); }); // Find media file links (common media extensions) document.querySelectorAll('a[href]').forEach(link => { const href = link.href.toLowerCase(); if(href.match(/\.(mp4|mp3|wav|ogg|webm|m4v)$/)) { console.log('Media link:', link.href); } }); // Find elements with media source attributes document.querySelectorAll('[src]').forEach(el => { const src = el.src.toLowerCase(); if(src.match(/\.(mp4|mp3|wav|ogg|webm|m4v)$/)) { console.log('Media element source:', el.src); } }); })();不要改变原先的结构
- Assistant
下面是在原有结构中新增提取目标媒体链接功能后的完整脚本,新增的代码片段放在原有代码逻辑后面,不改变已有代码结构:
// ==UserScript== // @name media-tracker // @namespace http://tampermonkey.net/ // @version 2025-05-23 // @description try to take over the world! // @author You // @match http://*/* // @grant none // ==/UserScript== (function() { 'use strict'; // Your code here... // Find video and audio elements document.querySelectorAll('video source, audio source').forEach(source => { console.log('Media source URL:', source.src); }); // Find media file links (common media extensions) document.querySelectorAll('a[href]').forEach(link => { const href = link.href.toLowerCase(); if(href.match(/\.(mp4|mp3|wav|ogg|webm|m4v)$/)) { console.log('Media link:', link.href); } }); // Find elements with media source attributes document.querySelectorAll('[src]').forEach(el => { const src = el.src.toLowerCase(); if(src.match(/\.(mp4|mp3|wav|ogg|webm|m4v)$/)) { console.log('Media element source:', el.src); } }); // 新增:提取 meta 中的 og:video 链接 const metaOgVideo = document.querySelector('meta[name="og:video"]'); if (metaOgVideo && metaOgVideo.content) { console.log('Meta og:video link:', metaOgVideo.content); } })();说明
- 新增部分代码使用了
document.querySelector('meta[name="og:video"]')获取页面中<meta name="og:video">标签; - 如果找到该标签且
content属性存在,则输出该值; - 这样实现了提取 html 中目标媒体链接的功能,而原有逻辑结构未做更改。
- 新增部分代码使用了
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.