设为首页收藏本站我的广告 劰载中...

UC社区 | UC论坛 | UC非官网论坛 | UC社区诺亚方舟号 | UC浏览器 上网最省流量的手机浏览器

查看: 15|回复: 2

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

[复制链接]

69

主题

94

帖子

106

积分

UC大班

Rank: 3Rank: 3

积分
106
发表于 昨天 10:25 | 显示全部楼层 |阅读模式
这个网站好像做了反爬的设置。

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

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


[code]// ==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[1],
            filename: match[1] + '.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([response.response], { 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(`




上一篇:澎湃工具箱

69

主题

94

帖子

106

积分

UC大班

Rank: 3Rank: 3

积分
106
 楼主| 发表于 昨天 21:12 | 显示全部楼层
奇怪,这下载服务器挂梯子速度明显起来了,难道是国外的?
回复

使用道具 举报

92

主题

1万

帖子

1万

积分

UC院士

我命由我不由天

Rank: 11Rank: 11Rank: 11Rank: 11

积分
15303
发表于 昨天 22:52 | 显示全部楼层
服务器在新加坡
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|UC社区-诺亚方舟号

GMT+8, 2026-8-4 05:21 , Processed in 0.070809 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表