From fd68df56f9b807b644bc4bd88ed5d018fb2f7732 Mon Sep 17 00:00:00 2001 From: Listen 1 Date: Mon, 23 Apr 2018 19:20:03 +0800 Subject: [PATCH] fix xiami playing problem (protocol relative url) --- README.md | 7 +++++-- js/provider/xiami.js | 12 +++++++++--- listen1.html | 2 +- manifest.json | 2 +- manifest_firefox.json | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e335a61..2dd9461 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -Listen 1 (Chrome Extension) V1.5.2 +Listen 1 (Chrome Extension) V1.6.0 ========== -(最后更新于2018年02月18日) +(最后更新于2018年04月23日) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE) @@ -45,6 +45,9 @@ Firefox打包安装 更新日志 ------- +`2018-04-23` +* 修复虾米音乐无法播放的问题 + `2018-02-18` * 修复无法创建歌单的bug diff --git a/js/provider/xiami.js b/js/provider/xiami.js index 247fd7c..0e7f2c8 100644 --- a/js/provider/xiami.js +++ b/js/provider/xiami.js @@ -30,6 +30,12 @@ var xiami = (function() { return unescape(s.join('')).replace(/\^/g, '0'); } + function handleProtocolRelativeUrl(url){ + var regex = /^.*?\/\//; + var result = url.replace(regex, 'http://'); + return result; + } + function xm_retina_url(s){ if (s.slice(-6, -4) == '_1') { return s.slice(0, -6) + s.slice(-4); @@ -56,7 +62,7 @@ var xiami = (function() { 'id': '', 'source_url': '' }; - default_playlist.cover_img_url = $(this).find('img')[0].src; + default_playlist.cover_img_url = handleProtocolRelativeUrl($(this).find('img')[0].src); default_playlist.title = $(this).find('h3 a')[0].title; var xiami_url = $(this).find('h3 a')[0].href; var list_id = xiami_url.split('?')[0].split('/').pop() @@ -115,8 +121,8 @@ var xiami = (function() { return; } var location = data.data.trackList[0].location; - sound.url = caesar(location); - track.img_url = xm_retina_url(data.data.trackList[0].pic); + sound.url = handleProtocolRelativeUrl(caesar(location)); + track.img_url = xm_retina_url(handleProtocolRelativeUrl(data.data.trackList[0].pic)); track.album = data.data.trackList[0].album_name; track.album_id = 'xmalbum_' + data.data.trackList[0].album_id; track.lyric_url = data.data.trackList[0].lyric_url; diff --git a/listen1.html b/listen1.html index 1e26e41..a0d2548 100644 --- a/listen1.html +++ b/listen1.html @@ -351,7 +351,7 @@

Listen 1 主页: http://listen1.github.io/listen1/

Listen 1 邮箱: githublisten1@gmail.com

-

当前版本 1.5.2 (本软件基于MIT协议开源免费)

+

当前版本 1.6.0 (本软件基于MIT协议开源免费)

diff --git a/manifest.json b/manifest.json index 41526f0..a9dcfc4 100644 --- a/manifest.json +++ b/manifest.json @@ -15,7 +15,7 @@ "manifest_version": 2, "name": "Listen 1", "permissions": [ "notifications", "unlimitedStorage", "downloads", "storage", "contextMenus", "tabs", "*://music.163.com/*", "*://*.xiami.com/*", "*://*.qq.com/*", "*://api.github.com/*", "*://github.com/*", "webRequest", "webRequestBlocking"], - "version": "1.5.2", + "version": "1.6.0", "web_accessible_resources": [ "images/*" ], "content_scripts": [{ "matches": ["https://listen1.github.io/listen1/*"], diff --git a/manifest_firefox.json b/manifest_firefox.json index cf64fc7..e8195b2 100644 --- a/manifest_firefox.json +++ b/manifest_firefox.json @@ -21,7 +21,7 @@ "manifest_version": 2, "name": "Listen 1", "permissions": [ "notifications", "unlimitedStorage", "downloads", "storage", "contextMenus", "tabs", "*://music.163.com/*", "*://*.xiami.com/*", "*://*.qq.com/*", "*://api.github.com/*", "*://github.com/*", "webRequest", "webRequestBlocking"], - "version": "1.5.2", + "version": "1.6.0", "web_accessible_resources": [ "images/*" ], "content_scripts": [{ "matches": ["https://listen1.github.io/listen1/*"],