-
Notifications
You must be signed in to change notification settings - Fork 76
/
index.html
123 lines (108 loc) · 3.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>抖音桌面版 By Golmic</title>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
</head>
<style>
body {
margin: 0;
}
img {
margin: 0 10px 0 10px;
width: 100px;
height: 100px;
}
video {
margin-top: 5px;
max-width: 100%;
}
p {
margin: 0 10px 5px 0;
}
#info {
margin-top: 10px;
display: flex;
}
.center {
text-align: center;
}
footer {
margin-top: 20px;
}
#update {
color: blue;
text-decoration: underline;
}
</style>
<body>
<div class="center">
<video id="video" controls loop preload="auto" height=500></video>
</div>
<div id="message" class="center"></div>
<div id="info">
<img id="avatar" src="" alt="avatar">
<div>
<b>
<p id="username"></p>
</b>
<p id="description"></p>
</div>
</div>
<footer class="center">
<p>Made with love by
<a href="https://github.com/lujqme/">Golmic</a>
</p>
<p>Give me a star on
<a href="https://github.com/lujqme/douyin">Github</a>!</p>
</footer>
</body>
<script>
function getPageUrl() {
axios.get('http://dy.golmic.com')
.then(function (response) {
var package = require("./package.json");
if (response.data.version > package.version) {
let message = '版本太低,请<a id="update">前往升级</a>'
document.getElementById('message').innerHTML = message;
}
if (response.data.code === 0) {
getVideoInfo(response.data.url);
} else {
alert(response.data.message);
}
})
.catch(function (error) {
alert('请求失败,请检查网络环境以及与服务器连接是否正常');
console.log(error);
});
}
function getVideoInfo(pageUrl) {
axios.get(pageUrl)
.then(function (response) {
const data = response.data;
const avatar = data.match('<div class="avatar[^"]+"><img src="([^"]+)')[1];
document.getElementById('avatar').setAttribute('src', avatar);
const username = data.match('<p class="name.*?>(.*?)</p>')[1];
document.getElementById('username').innerText = username;
const description = data.match('<p class="desc">(.*?)</p>')[1];
document.getElementById('description').innerText = description;
const videoSrc = data.match('playAddr: ?"([^"]+)')[1];
var video = document.getElementById('video');
video.setAttribute('src', videoSrc);
video.play();
})
.catch(function (error) {
alert('请求失败,请检查网络环境以及与服务器连接是否正常');
console.log(error);
});
}
window.onload = getPageUrl;
const shell = require('electron').shell
document.getElementById('message').addEventListener('click', function (event) {
console.log(event);
shell.openExternal("https://github.com/lujqme/douyin/releases")
})
</script>
</html>