导出QQ歌单

导出完整的QQ歌单信息,用于到其它地方搜索、下载

目前為 2020-11-10 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         导出QQ歌单
// @namespace    https://www.柴门.wooddoor/
// @version      0.1
// @description  导出完整的QQ歌单信息,用于到其它地方搜索、下载
// @author       柴门
// @match        https://y.qq.com/musicmac/v6/playlist/detail.html?id=*
// @grant        none
// @require      https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...

    setTimeout(function () {////定时5秒后运行一次
        $("#songlist_box").before(`<div style="display:inline;z-index:999;"><textarea style="height:100px;width:100%;" id="songlist__input" readonly="readonly" /><button  id="save">尝试保存</button></div>`);
        $("#songlist__input").val("mid\t歌曲名\t歌手名\tsingermid\tsingerid\talbummid\trid\talbum_name\tsonglist__time\n");
        console.log($('.songlist__li').length);
        $(".songlist__li").each(function(index,domEle){
          //console.log($(this).text());
          //alert($(this).text());
          var mid = $(this).find(".songlist__item").attr("mid");//不知啥,先记录保存下来再说
          
          var title = $(this).find(".mod_songname__name").attr("title");//歌曲名
          
          var singer_name = $(this).find(".singer_name").attr("title");//歌手名,或:$(".singer_name").text();
          var singermid = $(this).find(".singer_name").attr("data-singermid");//不知啥,先记录保存下来再说
          var singerid = $(this).find(".singer_name").attr("data-singerid");//不知啥,先记录保存下来再说
          
          var albummid = $(this).find(".songlist__album").attr("data-albummid");//不知啥,先记录保存下来再说
          var rid = $(this).find(".songlist__album").attr("data-rid");//不知啥,先记录保存下来再说
          var album_name = $(this).find(".songlist__album").text();//专辑名
          
          var songlist__time = $(this).find(".songlist__time").text();//歌曲时长
          
          $("#songlist__input").val($("#songlist__input").val() + mid + "\t" + title + "\t" + singer_name + "\t" + singermid + "\t" + singerid + "\t" + albummid + "\t" + rid + "\t" + album_name + "\t" + songlist__time + "\n");
          //$("#songlist__input").val( $("#songlist__input").val() + "{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}\n".format(mid, title, singer_name, singermid, singerid, albummid, rid, album_name, songlist__time) );
        });
      
      	//============javascript – 将HTML5 textarea内容保存到文件:https://www.jb51.cc/js/159069.html============//
          function saveTextAsFile() {
      			var textToWrite = $("#songlist__input").val();//document.getElementById('songlist__input').innerHTML;
      			var textFileAsBlob = new Blob([ textToWrite ],{ type: 'text/plain' });
      			var fileNameToSaveAs = "songlist.xls";//将歌单下载保存为songlist.xls文件
     
      			var downloadLink = document.createElement("a");
      			downloadLink.download = fileNameToSaveAs;
      			downloadLink.innerHTML = "Download File";
      			if (window.webkitURL != null) {
        			// Chrome allows the link to be clicked without actually adding it to the DOM.
        			downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
      			} else {
        			// Firefox requires the link to be added to the DOM before it can be clicked.
        			downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
        			downloadLink.onclick = destroyClickedElement;
        			downloadLink.style.display = "none";
        			document.body.appendChild(downloadLink);
      			}
     
      			downloadLink.click();
    			}
     
    			var button = document.getElementById('save');
    			button.addEventListener('click',saveTextAsFile);
     
    			function destroyClickedElement(event) {
      			// remove the link from the DOM
      			document.body.removeChild(event.target);
    			}
      	//============javascript – 将HTML5 textarea内容保存到文件:https://www.jb51.cc/js/159069.html============//
      

    }, 5000)
})();