您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
喜马拉雅音乐或视频下载
当前为
// ==UserScript== // @name ximalaya-download // @namespace http://greasyfork.icu/zh-CN/users/135090 // @grant none // @version 1.4.5 // @author zwb83925462 // @license BSD // @description 喜马拉雅音乐或视频下载 // @run-at document-end // @require https://registry.npmmirror.com/ajax-hook/3.0.3/files/dist/ajaxhook.min.js // @require https://registry.npmmirror.com/crypto-js/4.2.0/files/crypto-js.js // @require https://registry.npmmirror.com/jquery/3.7.1/files/dist/jquery.min.js // @match https://www.ximalaya.com/sound/* // @match https://www.ximalaya.com/album/* // @match https://m.ximalaya.com/album/* // @match https://m.ximalaya.com/selfshare/album* // @match https://m.ximalaya.com/m-revision/common/album/* // ==/UserScript== setTimeout(function(){ 'use strict'; //获取单曲解析结果 if (location?.pathname?.indexOf("sound")>0){ var playurl; if (window.location.pathname.indexOf("sound")>0){ var trackid=window.location.pathname.split("/")[2]; var stitle="xm"; var xmitem={ id:trackid, ttl:stitle }; setTimeout(function(){ var link = document.createElement("a"); var container = document.body; link.id="mp4"; link.style="position:fixed;top:10%;left:2%"; link.style.display = "block"; link.style.color = "#230de5"; getAllMusicURL2(xmitem).then(result=>{ playurl=result?.toString(); return playurl; }).then(data=>{ if (data == undefined){ link.textContent="未购买,无法下载"; link.style.fontSize = "20px"; link.style.color="#F00"; } else { link.download=xmitem.ttl; link.textContent=xmitem.ttl; console.log(link.href=data); } }); container.append(link); },2000); } async function getAllMusicURL2(item) { function decrypt(t) { return CryptoJS.AES.decrypt({ ciphertext: CryptoJS.enc.Base64url.parse(t) }, CryptoJS.enc.Hex.parse('aaad3e4fd540b0f79dca95606e72bf93'), { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }).toString(CryptoJS.enc.Utf8); } var res = null; var ares = null; const timestamp = Date.parse(new Date()); var url = `https://www.ximalaya.com/mobile-playpage/track/v3/baseInfo/${timestamp}?device=web&trackId=${item.id}&forVideo=true&needMp4=true`; var aurl =`https://www.ximalaya.com/mobile-playpage/track/v3/baseInfo/${timestamp}?device=web&trackId=${item.id}`; $.ajax({ type: 'get', url: aurl, async: false, dataType: "json", success: function(resp) { try { ares = decrypt(resp.trackInfo.playUrlList[0].url); item.ttl = resp.trackInfo.title; } catch (e) { console.log("无效"); } } }); $.ajax({ type: 'get', url: url, async: false, dataType: "json", success: function(resp) { try { res = decrypt(resp.trackInfo.playUrlList[0].url); item.ttl += ".mp4"; } catch (e) { console.log("解密错误,无视频"); res=ares; item.ttl += ".m4a"; } } }); return res; } } //PC视图 if (location.pathname.indexOf("/album/") == 0 && location.hostname == "www.ximalaya.com"){ var abid=location.pathname.indexOf("/album/") == 0 ? location.pathname.split("/")[2] : "77545064"; var abapi=`https://m.ximalaya.com/m-revision/common/album/queryAlbumTrackRecordsByPage?albumId=${abid}&page=1&pageSize=10&asc=true`; location.href=abapi; } //移动版视图 if (location.pathname.indexOf("/album/") == 0 && location.hostname == "m.ximalaya.com"){ window.location.href="https://www.ximalaya.com/album/"+location.pathname.split("/")[2]; } //移动版分享视图 if (location.pathname.indexOf("/selfshare/album") == 0 && location.hostname == "m.ximalaya.com"){ window.location.href="https://www.ximalaya.com/album/"+location.pathname.split("/")[3]; } if (location.pathname.indexOf("/m-revision/common/album/") == 0 && location.hostname == "m.ximalaya.com"){ var alt=[]; var ttls=[]; setTimeout(function(){ fetch(location.href,{method:"get",headers:{'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'},accept:"*/*"}) .then(res=>{var jsondata=res?.json();return jsondata;}) .then(res=>{ var trackcount=res?.data?.totalCount; var pagenums=(trackcount/10 | 0) + (trackcount % 10 >0 ? 1 : 0); //var pagenums = (trackcount % 100 >0 ? trackcount+100 : trackcount) / 100 | 0; console.log(pagenums); var tracks=res?.data?.trackDetailInfos; if (tracks == undefined){ alert(pagenums+"页,请刷新重试"); }else{ tracks.forEach(i=>{ alt.push(i.pageUriInfo.url); ttls.push(i.trackInfo.title); }); } return pagenums; }) .then(pns => { if (pns > 1){ var morehtm = `<p id=tip>专辑曲目超过10,请修改API参数后再访问.最大页码为${pns}</p>`; var alink=document.createElement("p"); alink.innerHTML=morehtm; document.body.append(alink); } var h2p=document.createElement("ul"); h2p.id="h2u"; h2p.position="absolute"; h2p.style.display = "table"; h2p.style.color = "#230de5"; h2p.style.listStyle = 'decimal'; h2p.style.paddingTop="0"; h2p.style.paddingBottom="50px"; document.body.append(h2p); ttls.forEach((it,n)=>{ console.log(it,n+1); var ulli=document.createElement("li"); var plink=document.createElement("a"); plink.href="https://www.ximalaya.com"+alt[n]; plink.target="_blank"; plink.style.color="#088"; plink.style.fontSize="20px"; plink.textContent=(n+1).concat(".")+it; ulli.append(plink); document.querySelector("#h2u").append(ulli); }); }); },2000); } },100);