Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

更新 UA 列表,更改随机 UA 相关逻辑 #922

Merged
merged 6 commits into from
Sep 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
.DS_Store
node_modules
*.log

.idea/


.idea
.vscode
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
## 安装

```shell
$ git clone git@github.com:Binaryify/NeteaseCloudMusicApi.git
$ git clone https://github.com/Binaryify/NeteaseCloudMusicApi.git
$ npm install
```

Expand Down
154 changes: 78 additions & 76 deletions public/avatar_update.html
Original file line number Diff line number Diff line change
@@ -1,80 +1,82 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>更新头像</title>
</head>
<body>
<input id="file" type="file" name="filename" />
<img id="avatar" style="height: 200px; width: 200px; border-radius: 50%;" />
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0-0/axios.min.js
<html lang="zh">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>更新头像</title>
</head>

<body>
<input id="file" type="file" name="filename" />
<img id="avatar" style="height: 200px; width: 200px; border-radius: 50%;" />
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0-0/axios.min.js
"></script>
<script>
const phone = ''
const password = ''
const port = 3000
let cookieToken = ''
if (!phone || !password) {
const msg = '请设置你的手机号码和密码'
alert(msg)
throw new Error(msg)
}
<script>
const phone = ''
const password = ''
let cookieToken = ''
if (!phone || !password) {
const msg = '请设置你的手机号码和密码'
alert(msg)
throw new Error(msg)
}

main()
login()
async function main() {
document.querySelector('input[type="file"]').addEventListener(
'change',
function (e) {
var file = this.files[0]
upload(file)
},
false
)
const res = await axios({
url: `http://localhost:${port}/user/detail?uid=32953014&timestamp=${Date.now()}`,
withCredentials: true, //关键
})
document.querySelector('#avatar').src = res.data.profile.avatarUrl
}
async function login() {
const res = await axios({
url: `http://localhost:${port}/login/cellphone?phone=${phone}&password=${password}`,
withCredentials: true, //关键
})
cookieToken = res.data.cookie
}
async function upload(file) {
var formData = new FormData()
formData.append('imgFile', file)
const imgSize = await getImgSize(file)
const res = await axios({
method: 'post',
url: `http://localhost:3000/avatar/upload?cookie=${cookieToken}&imgSize=${imgSize.width}&imgX=0&imgY=0&timestamp=${Date.now()}`,
headers: {
'Content-Type': 'multipart/form-data',
},
data: formData,
})
document.querySelector('#avatar').src = res.data.data.url
}
function getImgSize(file) {
return new Promise((resolve, reject) => {
let reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = function (theFile) {
let image = new Image()
image.src = theFile.target.result
image.onload = function () {
resolve({
width: this.width,
height: this.height
})
}
main()
login()
async function main() {
document.querySelector('input[type="file"]').addEventListener(
'change',
function (e) {
var file = this.files[0]
upload(file)
},
false
)
const res = await axios({
url: `/user/detail?uid=32953014&timestamp=${Date.now()}`,
withCredentials: true, //关键
})
document.querySelector('#avatar').src = res.data.profile.avatarUrl
}
async function login() {
const res = await axios({
url: `/login/cellphone?phone=${phone}&password=${password}`,
withCredentials: true, //关键
})
cookieToken = res.data.cookie
}
async function upload(file) {
var formData = new FormData()
formData.append('imgFile', file)
const imgSize = await getImgSize(file)
const res = await axios({
method: 'post',
url: `http://localhost:3000/avatar/upload?cookie=${cookieToken}&imgSize=${imgSize.width}&imgX=0&imgY=0&timestamp=${Date.now()}`,
headers: {
'Content-Type': 'multipart/form-data',
},
data: formData,
})
document.querySelector('#avatar').src = res.data.data.url
}
function getImgSize(file) {
return new Promise((resolve, reject) => {
let reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = function (theFile) {
let image = new Image()
image.src = theFile.target.result
image.onload = function () {
resolve({
width: this.width,
height: this.height
})
}
})
}
</script>
</body>
</html>
}
})
}
</script>
</body>

</html>
30 changes: 20 additions & 10 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<!DOCTYPE html>
<html>
<html lang="zh">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>网易云音乐 API</title>
</head>

<body>
<h1>网易云音乐 API</h1>
当你看到这个页面时,这个服务已经成功跑起来了~
Expand All @@ -17,32 +19,40 @@ <h2>例子:</h2>
<li>3. <a href="/dj/program?rid=336355127">电台节目</a></li>
</ul>
<style>
html,body{
html,
body {
height: 100vh;
width: 100vw;
margin: 0;
padding: 0;
background: #ffffff;
text-align: center;
margin-top:30px;
margin-top: 30px;
overflow: hidden;
}
*{
color:rgb(100,100,100);

* {
color: rgb(100, 100, 100);
}
a{
color:#42b983;

a {
color: #42b983;
}
ul,li{

ul,
li {
margin: 0;
}
ul{

ul {
margin-left: -40px;
line-height: 30px;
}
li{

li {
list-style: none;
}
</style>
</body>

</html>
Loading