Greasy Fork

Greasy Fork is available in English.

酷狗音乐mp3解析

解析酷狗音乐,或得播放链接

目前为 2022-12-06 提交的版本,查看 最新版本

// ==UserScript==
// @name         酷狗音乐mp3解析
// @namespace    yeyu
// @version      0.1
// @description  解析酷狗音乐,或得播放链接
// @author       You
// @match        http*://www.kugou.com/mixsong/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=kugou.com
// @require      https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js
// @grant        GM_xmlhttpRequest
// @license      MIT
// ==/UserScript==
//https://www.kugou.com/mixsong/7myesm23.html#hash=2DE3E063E1A66185F514FBEE707E7748&album_id=64295658&album_audio_id=461820262
(function() {
	'use strict';
	var kg = function() {

		function Guid() {
			function e() {
				return (65536 * (1 + Math.random()) | 0).toString(16).substring(1)
			}
			return e() + e() + "-" + e() + "-" + e() + "-" + e() + "-" + e() + e() + e()
		}
		console.log(Guid())
		//console.log(md5(Guid()));
		console.log("myhash:" + Hash)
		console.log("album_id:" + album_id)
		var mid = md5(Guid());
		GM_xmlhttpRequest({
			method: "get",
			url: 'https://wwwapi.kugou.com/yy/index.php?r=play/getdata&hash='+Hash+'&mid='+mid+'&album_id='+ album_id,
			headers: {
				"Content-Type": "application/json",
				"Cookie" : "kg_mid="+mid
			},
			onload: function(res) {
				if (res.status === 200) {
					console.log('成功')
					var ret = JSON.parse(res.response)
					console.log(ret.data.play_url)
					var aa = document.createElement("a")
					aa.href = ret.data.play_url;
					aa.innerText = "已解析完成,点击下载"
					$("#openKugou").append(aa)
				} else {
					console.log('失败')
					console.log(res)
				}
			},
			onerror: function(err) {
				console.log('error')
				console.log(err)
			}
		});
	}

	setTimeout(kg, 2500)
})();