// ==UserScript==
// @name 天天动次打次
// @namespace https://bbs.tampermonkey.net.cn/
// @version 0.1.2
// @description 终有一天,人类会变成只会唱歌跳舞的物种!酷狗:✅MV下载 ...,酷我:✅MV下载 ...,QQ:✅MV下载 ...
// @author You
// @icon https://bpic.51yuansu.com/pic3/cover/02/36/79/59c241007576b_610.jpg
// @require https://scriptcat.org/lib/881/%5E1.2.0/script-statistics.js
// @match http*://www.kugou.com/*
// @match http*://www.kuwo.cn/*
// @match http*://y.qq.com/*
// @match http*://music.163.com/*
// @match http*://music.91q.com/*
// @match http*://music.migu.cn/*
// @connect scriptcat.org
// @run-at document-start
// @grant unsafeWindow
// @grant GM_xmlhttpRequest
// @grant GM_setValue
// @grant GM_getValue
// @antifeature tracking
// ==/UserScript==
(function () {
'use strict';
var obj = {
kugou: {},
kuwo: {},
yqq: {},
m163: {},
m91q: {},
migu: {},
};
obj.kugou.run = function () {
if (unsafeWindow.jQuery) {
obj.statistic();
var url = location.href;
if (url.indexOf(".kugou.com/mv/") > 0 || url.indexOf(".kugou.com/mvweb/") > 0) {
obj.kugou.mvPage();
}
}
else {
setTimeout(obj.kugou.run, 100);
}
};
obj.kuwo.run = function () {
if (unsafeWindow?.__NUXT__?.data && unsafeWindow?.$nuxt?._router) {
var url = location.href;
var routePath = unsafeWindow.__NUXT__.routePath;
if (routePath == location.pathname && url.indexOf(routePath) > 0) {
obj.statistic();
if (url.indexOf(".kuwo.cn/mvplay/") > 0) {
obj.kuwo.mvPage();
};
}
else {
location.reload();
}
unsafeWindow.$nuxt._router.afterHooks.push(function () {
setTimeout(obj.kuwo.run, 500);
});
}
else {
setTimeout(obj.kuwo.run, 500);
}
};
obj.yqq.run = function () {
obj.statistic();
var url = location.href;
if (url.indexOf("y.qq.com/n/ryqq/mv") > 0) {
obj.yqq.mvPage();
}
};
obj.m163.run = function () {
obj.statistic();
};
obj.m91q.run = function () {
obj.statistic();
};
obj.migu.run = function () {
obj.statistic();
};
obj.kugou.mvPage = function () {
unsafeWindow.jQuery(document).ajaxComplete(function (event, xhr, options) {
var requestUrl = options.url;
if (requestUrl.indexOf("/play/mv") > -1) {
var response = xhr.responseText;
try {
response = JSON.parse(response);
} catch (e) { }
if (response && response.status == 1) {
var mvinfo = {}, definition = { fhd: "1080P 全高清", hd: "720P 高清", qhd: "540P 标清", sd: "480P 标清", ld: "360P 普清" };
const { info, play, privilege } = response.data;
Object.keys(info.h264).forEach(function (template) {
if (info.h264[template]) {
const [k, v] = template.split("_");
if (!mvinfo[k]) {
mvinfo[k] = {};
mvinfo[k].definition = definition[k] || "未知";
}
mvinfo[k][v] = info.h264[template];
if (v == "hash") {
Object.assign(mvinfo[k], play[info.h264[template]]);
}
}
});
unsafeWindow.jQuery(".mv_appdownloadBtn").empty().attr({ target: "", href: "javascript:;", title: "MV 下载" }).on("click", function () {
var t = unsafeWindow.dialog.list;
t.downloadd = t.downloadd || unsafeWindow.dialog({
title: "下載MV",
skin: "download_popup",
fixed: !0,
content: [
'
"
].join(""),
onshow: function () {
unsafeWindow.jQuery(".btnDl").off("click").on("click", function (e) {
//e.preventDefault();
//t.downloadd.close().remove()
})
},
onclose: function () {
t.downloadd = null;
}
}).show();
});
}
}
});
};
obj.kuwo.mvPage = function () {
var sources = [], data = unsafeWindow.__NUXT__.data;
if (Array.isArray(data)) {
data.forEach(function (item) {
item.playerOptions.sources.forEach(function (item) {
item.type == "video/mp4" && sources.push(item);
});
});
}
if (sources.length) {
var node = document.querySelector("#__layout > div > div.model_out > div");
if (node) {
node.querySelector("div:nth-child(2)").innerHTML += '' + sources.slice(0, 2).map(item => '
下载酷我音乐MV ').join("\n");
}
else {
var btn = document.querySelector(".play_out .btns div:nth-child(2)");
if (btn.innerText == "下载") {
btn.addEventListener("click", function (event) {
setTimeout(() => {
var node = document.querySelector("#__layout > div > div.model_out > div");
if (node) {
node.querySelector("div:nth-child(2) > div").innerHTML = sources.slice(0, 2).map(item => '下载酷我音乐MV').join("\n");
}
});
}, false);
}
}
}
};
obj.yqq.mvPage = function () {
var open = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function () {
this.addEventListener("load", function() {
if (this.readyState == 4 && this.status == 200) {
var responseURL = this.responseURL;
if (responseURL.indexOf("/cgi-bin/musicu.fcg") > 0) {
var response = this.response;
try { response = JSON.parse(response) } catch (error) { };
if (response?.code == 0) {
const { mvInfo, mvUrl } = response;
if (mvUrl.code == 0) {
var mvlist = [], qt = {
60: {
option: "4K超清",
text: "4k"
},
50: {
option: "1080P高帧率",
text: "高帧率"
},
40: {
option: "全高清1080P",
text: "全高清"
},
30: {
option: "超清720P",
text: "超清"
},
20: {
option: "高清480P",
text: "高清"
},
10: {
option: "标清360P",
text: "标清"
}
};
const { hls, mp4 } = mvUrl.data[Object.keys(mvUrl.data)[0]];
mp4.forEach(function (item) {
if (item.code == 0) {
Object.assign(item, qt[item.filetype]);
mvlist.push(item);
}
});
if (mvlist.length) {
var toolbar = document.querySelector(".mod_mv .mv__info .mv_toolbar");
if (toolbar) {
toolbar.insertAdjacentHTML(
"afterbegin",
'下载'
);
(toolbar.firstElementChild || toolbar.firstChild).addEventListener("click", function (event) {
document.querySelector(".yqq-dialog-root") || document.body.insertAdjacentHTML(
"beforeend",
''
);
var dialog = document.body.lastElementChild || document.body.lastChild;
dialog.querySelector(".yqq-dialog-close").onclick = function () {
document.body.removeChild(dialog);
};
}, false);
}
}
}
}
}
}
}, false);
open.apply(this, arguments);
};
};
obj.statistic = function () {
setTimeout(() => {
new SC_Statistic({
key: "mjrbbskyc1hihx66",
banFrame: false
})
});
};
obj.run = function () {
var url = location.href;
if (url.indexOf("www.kugou.com") > 0) {
obj.kugou.run();
console.log("=== 酷狗音乐 好棒棒!===");
}
else if (url.indexOf("www.kuwo.cn") > 0) {
obj.kuwo.run();
console.log("=== 酷我音乐 好棒棒!===");
}
else if (url.indexOf("y.qq.com") > 0) {
obj.yqq.run();
console.log("=== QQ音乐 好棒棒!===");
}
else if (url.indexOf("music.163.com") > 0) {
obj.m163.run();
console.log("=== 网易云音乐 好棒棒!===");
}
else if (url.indexOf("music.91q.com") > 0) {
obj.m163.run();
console.log("=== 千千音乐 好棒棒!===");
}
else if (url.indexOf("music.migu.cn") > 0) {
obj.m163.run();
console.log("=== 咪咕音乐 好棒棒!===");
}
};
return obj.run();
// Your code here...
})();