// ==UserScript== // @name 恢复虾米网页下载 // @namespace https://nich.work // @version 0.3 // @description For those who would like to download music from web page rather than electron based desktop client. // @author You // @match http://www.xiami.com // @match http://www.xiami.com/* // @grant unsafeWindow // @downloadURL none // ==/UserScript== (function() { 'use strict'; unsafeWindow.xm_download = function(id, type, ele) { if (type && type == 'song') { var pare = ele.parentNode.parentNode.parentNode; if (pare) { var data = pare.getAttribute('data-json'); data = JSON.parse(decodeURIComponent(data)); data.id = id; selectDownlodQuality(data); return; } } else { var url = 'http://www.xiami.com/download/pay?id=' + encodeURIComponent(id); window.open(url); } }; unsafeWindow.selectDownlodQuality = function(data) { var ht, warm, lowht, highht; if (data.LOW == 'FREE') { lowht = '
  • 流畅品质
  • '; } else if (data.LOW == 'NEED_PAY') { lowht = '
  • 付费流畅品质
  • '; } else { lowht = ''; } if (data.HIGH == 'FREE') { highht = '
  • 高品质
  • '; } else if (data.HIGH == 'NEED_PAY') { highht = '
  • 付费高品质
  • '; } else { highht = ''; } ht = '

    选择下载的品质

    ' + '
    ' + '' + '关闭'; showDialog('', ht); }; unsafeWindow.downloadalbum = function(id, type, me) { if (!$.cookie('user')) { showDialog('/member/poplogin'); return; } if (me) { var downloadstatus = me.getAttribute('data-downloadstatus'); // 0 不提供服务, 1 免费, 2 付费 if (downloadstatus == '0') { checkAlbumPermission('download'); return; } if (downloadstatus && downloadstatus == '2') { buyMusic('album', id, '下载'); return; } } prepareZipx('album', id); return; }; })();