+
63
-

chrome如何注入js捕获音频mp3地址并自动下载?

chrome如何注入js捕获音频mp3地址并自动下载?


网友回复

+
6
-

直接使用油猴脚本来提取音频,主要捕获通过 new Audio在js中直接播放url声音的网页,效果如下,点击即可下载本地:

800_auto

// ==UserScript==
// @name         Advanced Audio URL Catcher (JS Hook)
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Hooks the Audio() constructor and <audio>.src setter to capture dynamically played audio URLs and provides download links.
// @author       YourName
// @match        *://*/*
// @grant        GM_download
// @grant        GM_log
// @grant        unsafeWindow
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    // --- 配置 ---
    // 设置要忽略的URL模式(例如,短的提示音或广告)
    const IGNORE_PATTERNS = [
        /ad-sound\.mp3/i, // 忽略广告声音
        /\.wav$/i,         // 忽略 .wav 文件
        /notification\.mp3/i // 忽略通知音
    ];

    // 使用 Set 来存储已捕获的URL,自动处理重复项
    const capturedUrls = new Set();
    let panel = null;

    // --- 核心功能:捕获并显示URL ---
    function captureUrl(url) {
        // 1. 过滤无效或不想要的URL
        if (!url || typeof url !== 'string' || url.startsWith('blob:') || url.startsWith('data:')) {
            return;
        }

        // 2. 检查是否已捕获
        if (capturedUrls.has(ur...

点击查看剩余70%

我知道答案,我要回答