qtfm-download

蜻蜓FM-节目下载

目前為 2024-08-13 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name          qtfm-download
// @namespace     https://greasyfork.org/zh-CN/users/135090
// @version       0.5
// @author        zwb83925462
// @match         https://www.qtfm.cn/channels/*/programs/*/
// @match         https://www.qingting.fm/channels/*/programs/*/
// @icon          https://www.qingting.fm/favicon.ico
// @grant         none
// @run-at        document-end
// @description   蜻蜓FM-节目下载
// @license       CC
// ==/UserScript==
(function() {
    'use strict';
    setTimeout(function(){
        var qtapi=null;
        if (location.hostname.includes("qingting.fm")) {
            qtapi="https://webapi.qingting.fm/api/mobile/"+location.href.substring(24);
        } else if (location.hostname.includes("qtfm.cn")) {
            qtapi="https://webapi.qtfm.cn/api/mobile/"+location.href.substring(20);
        }
        fetch(qtapi).then(res=>{return res.text()}).then(txt=>{return JSON.parse(txt)?.programInfo})
            .then(pinfo=>{
                console.log(pinfo);
                var au=pinfo?.audioUrl;
                var ahref=null;
                if (pinfo?.saleStatus == "free" ){
                    ahref=au;
                    var avd=document.createElement('video');
                    avd.style.width="800px";
                    avd.style.height="auto";
                    avd.style.position="fixed";
                    avd.style.top="450px";
                    avd.style.left="2px";
                    avd.src=ahref;
                    avd.setAttribute('controls','');
                    avd.controlslist="noremoteplayback";
                    document.body.append(avd);
                } else {
                    ahref="#";
                }
                /*
                {
                    var atk="&access_token="+JSON.parse(localStorage.accessToken)?.value;
                    atk += "&"+document.cookie.substring(document.cookie.indexOf('qingting'),document.cookie.indexOf('Hm_lpvt')-2);
                    ahref=au+atk;
                }
                */
                console.log(ahref);
                var aqt=document.createElement("a");
                aqt.style.position="fixed";
                aqt.style.top="250px";
                aqt.style.left="2px";
                aqt.href=ahref;
                aqt.download=pinfo?.title+".m4a";
                aqt.value=pinfo?.title;
                aqt.textContent=pinfo?.saleStatus == "free" ? pinfo?.title : "收费音频,无法下载";
                document.body.append(aqt);
            });
    });
})();