Google 发表于 2026-8-3 10:25:53

听书网点击下载并重命名文件名 篡改猴脚本

这个网站好像做了反爬的设置。

打开多了或者访问频繁了会失败。

一个一个点,说实话有点麻烦,凑合用吧。
www.ting13.cc


// ==UserScript==
// @name         13听书网 · 精准下载(自动命名·进度显示)
// @namespace    https://www.ting13.cc/
// @version      5.0
// @description点击下载,通过流方式获取音频,自动命名,显示下载进度,无干扰。
// @author       You
// @match      https://www.ting13.cc/play/*
// @grant      GM_setClipboard
// @grant      GM_xmlhttpRequest
// @connect      mp3nn.ysxs.top
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function getChapterInfo() {
      const h1 = document.querySelector('h1');
      if (!h1) return null;
      const raw = h1.textContent.trim();
      const match = raw.match(/正在播放[::]\s*(.+?)\.mp3$/);
      if (!match) return null;
      return {
            full: match,
            filename: match + '.mp3'
      };
    }

    function getAudioUrl() {
      const audio = document.querySelector('audio');
      if (audio && audio.src) return audio.src;
      const jplayer = document.getElementById('jquery_jplayer_1');
      if (jplayer) {
            const audioEl = jplayer.querySelector('audio');
            if (audioEl && audioEl.src) return audioEl.src;
      }
      return null;
    }

    function downloadWithProgress(url, filename) {
      const btn = document.getElementById('ting13-download-btn');
      if (!btn) return;

      btn.disabled = true;
      btn.textContent = '⏳ 0%';

      GM_xmlhttpRequest({
            method: 'GET',
            url: url,
            responseType: 'blob',
            onprogress: function(ev) {
                if (ev.lengthComputable) {
                  const percent = Math.round((ev.loaded / ev.total) * 100);
                  btn.textContent = `⏳ ${percent}%`;
                } else {
                  btn.textContent = '⏳ 下载中...';
                }
            },
            onload: function(response) {
                const blob = new Blob(, { type: 'audio/mpeg' });
                const blobUrl = URL.createObjectURL(blob);
                const a = document.createElement('a');
                a.href = blobUrl;
                a.download = filename;
                document.body.appendChild(a);
                a.click();
                document.body.removeChild(a);
                setTimeout(() => URL.revokeObjectURL(blobUrl), 5000);
                btn.textContent = '✅ 完成';
                setTimeout(() => {
                  btn.textContent = '⬇ 下载';
                  btn.disabled = false;
                }, 2000);
            },
            onerror: function() {
                alert('下载失败,请检查网络或重试。');
                btn.textContent = '⬇ 下载';
                btn.disabled = false;
            }
      });
    }

    function createWidget(info, audioUrl) {
      const old = document.getElementById('ting13-download-widget');
      if (old) old.remove();
      if (!audioUrl) return;

      const widget = document.createElement('div');
      widget.id = 'ting13-download-widget';
      widget.style.cssText = `
            position: fixed;
            bottom: 20px;
            right: 20px;
            z-index: 9999;
            background: rgba(20,20,20,0.85);
            backdrop-filter: blur(4px);
            color: #eee;
            padding: 8px 14px;
            border-radius: 8px;
            border: 1px solid #444;
            font-size: 13px;
            font-family: sans-serif;
            display: flex;
            align-items: center;
            gap: 10px;
            pointer-events: auto;
            opacity: 0.8;
            transition: opacity 0.3s;
            box-shadow: 0 2px 10px rgba(0,0,0,0.4);
      `;

      widget.innerHTML = `
            <span style="color:#aaa;font-size:12px;max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;" title="${info.full}">${info.full}</span>
            <button id="ting13-download-btn" style="background:#00d4aa;border:none;color:#000;padding:4px 14px;border-radius:4px;font-weight:bold;cursor:pointer;font-size:12px;">
                ⬇ 下载
            </button>
            <span id="close-widget" style="color:#666;cursor:pointer;font-size:16px;line-height:1;">✕</span>
      `;

      document.body.appendChild(widget);

      document.getElementById('ting13-download-btn').addEventListener('click', (e) => {
            e.stopPropagation();
            downloadWithProgress(audioUrl, info.filename);
      });

      document.getElementById('close-widget').addEventListener('click', () => {
            widget.style.opacity = '0';
            setTimeout(() => widget.remove(), 300);
      });

      widget.addEventListener('mouseenter', () => widget.style.opacity = '1');
      widget.addEventListener('mouseleave', () => widget.style.opacity = '0.8');
    }

    function main() {
      const info = getChapterInfo();
      if (!info) return;
      const audioUrl = getAudioUrl();
      if (!audioUrl) return;

      try {
            GM_setClipboard(info.full);
      } catch (e) {}

      createWidget(info, audioUrl);
      console.log(`

Google 发表于 2026-8-3 21:12:44

奇怪,这下载服务器挂梯子速度明显起来了,难道是国外的?

哪吒 发表于 2026-8-3 22:52:21

服务器在新加坡:摇头

Google 发表于 2026-8-8 12:15:32

难怪,也是,这个网站都是,大部分资源都是喜马拉雅收费的。

对了,这个网站下的东西,然后它音频格式写入了它网站的网址名称写入了MP3标签。哦,搞忘了。嗯,对了,要用那个音频标签把它全部给它清空一下,批量。不然放入手机的话,播放器读的是MP3标签。
页: [1]
查看完整版本: 听书网点击下载并重命名文件名 篡改猴脚本