diff --git a/README.md b/README.md index d9562eb..6e2eb3b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Listen 1 (Chrome Extension) (最后更新于2017年10月16日) +Listen 1 (Chrome Extension) (最后更新于2017年11月17日) ========== [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE) @@ -36,6 +36,11 @@ Firefox打包安装 更新日志 ------- +`2017-11-17` + +* 在我的歌单页面增加“打开歌单”功能,可打开支持网页的歌单链接地址。这样就可以导入你喜欢的歌单了。 +* HTTP请求头部的Origin字段设置为正常网址 + `2017-10-16` * 修复QQ音乐歌单翻页显示重复的问题(感谢@Moobusy的提交) diff --git a/css/player.css b/css/player.css index 3b68446..78361c2 100644 --- a/css/player.css +++ b/css/player.css @@ -971,7 +971,7 @@ li { bottom: 20px; } -.dialog-editplaylist .confirm-button { +.dialog-editplaylist .confirm-button, .dialog-open-url .confirm-button { margin-right: 82px; margin-left: 93px; } @@ -1028,7 +1028,9 @@ li { color: #333333; } - +.source-list .open-url-button { + border-radius: 4px; +} .settings-title { font-size: 20px; diff --git a/images/playbar.png b/images/playbar.png deleted file mode 100644 index 2bbe517..0000000 Binary files a/images/playbar.png and /dev/null differ diff --git a/js/app.js b/js/app.js index 27df81f..914d1a2 100644 --- a/js/app.js +++ b/js/app.js @@ -233,6 +233,10 @@ $scope.dialog_title = '连接到Last.fm'; $scope.dialog_type = 4; } + if (dialog_type == 5) { + $scope.dialog_title = '打开歌单'; + $scope.dialog_type = 5; + } }; $scope.chooseDialogOption = function(option_id) { @@ -480,7 +484,26 @@ } }); - + $scope.openUrl = function(url) { + loWeb.post({ + url: '/parse_url', + method: 'POST', + data: $httpParamSerializerJQLike({ + url: url + }), + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + } + }).success(function(data) { + var result = data.result; + if (result !== undefined) { + $scope.showPlaylist(result.id); + } + else { + Notification.info('未能打开输入的歌单地址'); + } + }); + } }]); diff --git a/js/background.js b/js/background.js index 336d1d7..bae3747 100644 --- a/js/background.js +++ b/js/background.js @@ -23,6 +23,7 @@ function hack_referer_header(details) { } var isRefererSet = false; + var isOriginSet = false; var headers = details.requestHeaders, blockingResponse = {}; @@ -30,7 +31,10 @@ function hack_referer_header(details) { if ((headers[i].name == 'Referer') && (referer_value != '')) { headers[i].value = referer_value; isRefererSet = true; - break; + } + if ((headers[i].name == 'Origin') && (referer_value != '')) { + headers[i].value = referer_value; + isOriginSet = true; } } @@ -41,6 +45,13 @@ function hack_referer_header(details) { }); } + if ((!isOriginSet) && (referer_value != '')) { + headers.push({ + name: "Origin", + value: referer_value + }); + } + blockingResponse.requestHeaders = headers; return blockingResponse; }; diff --git a/js/loweb.js b/js/loweb.js index 03cf785..30dd3a4 100644 --- a/js/loweb.js +++ b/js/loweb.js @@ -12,6 +12,10 @@ function getProviderByName(sourceName) { } } +function getAllProviders(){ + return [netease, xiami, qq]; +} + function getProviderByItemId(itemId) { var prefix = itemId.slice(0,2); if (prefix == 'ne') { @@ -122,6 +126,23 @@ function($rootScope, $log, $http, $httpParamSerializerJQLike) { } }; } + if (request.url.search('/parse_url') != -1) { + var url = getParameterByName('url', url+'?'+request.data); + var providers = getAllProviders(); + var result = undefined; + for(var i=0; i + +
+
+ + +
+ + + +
+ @@ -134,6 +145,12 @@
+
+ +
+
打开歌单
+
+