lizhiFM 荔枝FM 下载音乐

下载荔枝FM分享到音乐

当前为 2019-03-29 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         lizhiFM 荔枝FM 下载音乐
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  下载荔枝FM分享到音乐
// @require https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js
// @author       Zszen
// @match        https://www.lizhi.fm/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    //console.log('123');
    loopDetect();

    function loopDetect(){
       setTimeout(function(){
           if(!player){
               loopDetect();
               return;
           }
           dealMajor();
       },500);
    }
    function dealMajor(){
        var data = null;
        try{
            data = player.getList().models;
        }catch(e){
        }
        //data.cover
        //data.url
        let bro = $('div.playlist').find('span.playlist-item-index').parent().find('span.playlist-item-user-name');
        bro.css({width:'60px'});
        let container = $("<span class='lizhi-download' style='width:160px'></span>")
        let btDownMp3 = $('<span style="width:70px;"><a class="downmp3" href="#">下载音频</a></span>');
        let btDownImg = $('<span style="width:70px;"><a class="downimg" href="#"">下载封面</a></span>');
        container.append(btDownMp3);
        container.append(btDownImg);
        bro.after(container);
        let all = $("span.lizhi-download");
        for(let i=0;i<all.length;i++){
            //console.log(all[i]);
            let a = all.eq(i).find('a.downmp3');
            a.attr('index', i);
            let b = all.eq(i).find('a.downimg');
            b.attr('index', i);
            console.log(a);
            a.on('click',function(e){
                var data = player.getList().models[e.target.getAttribute('index')].attributes;
                window.open(data.url,"_blank");
            })
            b.on('click',function(e){
                var data = player.getList().models[e.target.getAttribute('index')].attributes;
                window.open(data.cover,"_blank");
            })
        }
    }
})();