天天动次打次
// ==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: [
'<div class="dialogContent clearfix">',
'<div class="contetText">', '<p><span class="warn_icon"></span>下载MV需要在酷狗音乐客户端操作</p></div>',
'<div class="dialogFooter clearfix">',
Object.keys(mvinfo).slice(0, 3).map(item => "<a href=\"" + mvinfo[item].downurl + "\" target=\"_blank\" class=\"btnDl\">" + mvinfo[item].definition + "</a>").join(""),
"</div>",
'<div class="dialogFooter clearfix">',
Object.keys(mvinfo).slice(3).map(item => "<a href=\"" + mvinfo[item].downurl + "\" target=\"_blank\" class=\"btnDl\">" + mvinfo[item].definition + "</a>").join(""),
"</div>",
"</div>"
].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 += '<div data-v-5cb78f71="" class="btns">' + sources.slice(0, 2).map(item => '<a data-v-5cb78f71="" href="' + item.src + '" target="_blank" class="load">下载酷我音乐MV</a></div>').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 => '<a data-v-5cb78f71="" href="' + item.src + '" target="_blank" class="load">下载酷我音乐MV</a>').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",
'<a class="btn_big_down" style="position: relative;display: inline-block;vertical-align: middle;width: 21px;height: 20px;background-position: 0 -120px;font-size: 0;background-image: -webkit-image-set(url(/ryqq/static/media/player.a628799e.png?max_age=2592000) 1x,url(/ryqq/static/media/player@2x.41e8450a.png?max_age=2592000) 2x);opacity: .8;"><span class="icon_txt">下载</span></a><i class="mv_toolbar__line"></i>'
);
(toolbar.firstElementChild || toolbar.firstChild).addEventListener("click", function (event) {
document.querySelector(".yqq-dialog-root") || document.body.insertAdjacentHTML(
"beforeend",
'<div><div class="yqq-dialog-root"><div class="yqq-dialog-mask"></div><div tabindex="-1" class="yqq-dialog-wrap" role="dialog"><div role="document" class="yqq-dialog yqq-dialog_centered" style="width: 440px;"><div tabindex="0" aria-hidden="true" style="width: 0px; height: 0px; overflow: hidden; outline: none;"></div><div class="yqq-dialog-content"><button type="button" aria-label="Close" class="yqq-dialog-close"><span class="yqq-dialog-close-x"></span></button><div class="yqq-dialog-body"><div class="mod_popup"><div class="popup__hd"><h2 class="popup__tit">QQ音乐提醒您</h2></div><div class="popup__bd"><div class="popup__bd_inner"><div class="popup__icon_tips icon_popup_note"></div><h3 class="popup__subtit popup__subtit--single" style="white-space: inherit;">下载歌曲需要在QQ音乐客户端操作!使用QQ音乐客户端获得高品质完整体验</h3><p class="popup__desc"></p></div></div>' +
'<div class="popup__ft">' +
mvlist.slice(0, 3).map(item => '<a href="' + item.freeflow_url[0] + '" target="_blank" class="upload_btns__item mod_btn_green">' + item.option + '</a>').join("\n") +
'</div>' +
'<div class="popup__ft">' +
mvlist.slice(3).map(item => '<a href="' + item.freeflow_url[0] + '" target="_blank" class="upload_btns__item mod_btn_green">' + item.option + '</a>').join("\n") +
'</div>' +
'</div></div></div><div tabindex="0" aria-hidden="true" style="width: 0px; height: 0px; overflow: hidden; outline: none;"></div></div></div></div></div>'
);
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...
})();