一条代码随机播放音乐

网络闲逛(不要问我毕业班为啥有时间闲逛,此闲非彼闲),逛到个一条代码随机播放音乐……(已废)

一条代码

1
<script src="https://api.lailal.cc/music/random_music.js"></script>

多条代码

1
2
3
4
5
6
7
8
9
<script>
var _rm = _rm || [];
(function() {
var rm = document.createElement("script");
rm.src = "https://api.lailal.cc/music/random_music.js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(rm, s);
})();
</script>

控制是否播放

1
2
3
4
5
6
if (confirm('是否播放随机音乐?')){
var rm = document.createElement("script");
rm.src = "https://api.lailal.cc/music/random_music.js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(rm, s);
}

原网页代码

为了尊重一下作者的劳动成果又不想留下链接,故而把代码出处贴上(可看可不看)

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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<!-------------------------------------------------------------------------// 
| 飞狐灵动网络技术有限公司 ( Www.Lailal.Com )
---------------------------------------------------------------------------//
| [ 网页设计、软件开发、平面设计、服务器租用、CDN加速、域名服务 ]
---------------------------------------------------------------------------//
| [ SEO优化、时时彩站、APP开发、百度排名、网站搭建、微信小程序 ]
---------------------------------------------------------------------------//
| E-mail: Admiuu@163.com 客服QQ:2058222220 / 2501888880
---------------------------------------------------------------------------//
| 赶 紧 联 系 我 们 吧 , 主 动 才 会 有 故 事 !
---------------------------------------------------------------------------//
| Copyright (c) 2008-2099 by:Lailal.Com All rights reserved.
---------------------------------------------------------------------------//
| 注意:请勿删除此段版权信息,否则由使用者引起的一切后果自负!
----------------------------------------------------------------------------->

<!DOCTYPE html>
<html lang="zh-CN">

<head>
<title>API助手管家 - 致力提供免费的互联网接口支持</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="keywords" content="API,接口调用,视频解析接口,音乐解析,二维码生成,一言句子,m3u8视频,QQ头像,随机图片,随机音乐">
<meta name="description" content="专注于免费API接口研发、供大众使用的接口网站!">
<link rel="icon" href="/favicon.ico">
<link rel="stylesheet" href="css/e8cc83a2c9534b9d93ea1d8b515c1f9f.css">
<link rel="stylesheet" href="css/material.indigo-pink.min.css">
<link rel="stylesheet" href="css/animate.min.css">
<link rel="stylesheet" href="css/aplayer.min.css">
<link rel="stylesheet" href="css/hitokoto.css">
<style>
.aplayer-lrc-contents > p {
color: #fff !important;
text-shadow: none !important;
}
</style>
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="js/7bdd7b01184d45c0b9a91f837a7ab4d8.js"></script>
<script>
window.dataLayer = window.dataLayer || [];

function gtag() {
dataLayer.push(arguments)
};
gtag('js', new Date());

gtag('config', 'UA-106578243-1');
</script>
<!-- BrowserHappy -->
<script>
var browsehappy_config = {
ie: 12,
type: 'box',
debug: false,
tip: "站点目前不支持 IE。请 ",
show: ['firefox', 'chrome']
};
</script>
<script src="js/browserhappy.min.js"></script>
</head>

<body style="position:absolute;">
<div class="background">
</div>
<div class="mdl-layout mdl-js-layout animated fadeIn">
<!--banner-->
<header class="mdl-layout__header mdl-layout__header--scroll mdl-layout__header--transparent" id="nav">
<div class="mdl-layout__header-row">
<!-- Title -->
<span class="mdl-layout-title">https API</span>
<!-- Add spacer, to align navigation to the right -->
<div class="mdl-layout-spacer"></div>
<!-- Navigation -->
<nav class="mdl-navigation">
<a class="mdl-navigation__link doLike" href="#">
<div id="like_number1" class="material-icons mdl-badge mdl-badge--overlap" data-badge="999">favorite
</div>
</a>
<a class="mdl-navigation__link" href="https://api.lailal.cc">使用 API</a>
<a class="mdl-navigation__link" href="https://weibo.com/chinazcwl"target="_blank">新浪微博</a>
<a class="mdl-navigation__link" href="https://www.1ziy.cn"target="_blank">Blog博客</a>
<a class="mdl-navigation__link" href="/partner"target="_blank">鸣谢⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄</a>

</nav>

</div>
</header>

<!--sidebar-->
<div class="mdl-layout__drawer">
<span class="mdl-layout-title">https API</span>
<nav class="mdl-navigation">
<a class="mdl-navigation__link doLike" href="https://api.lailal.cc/">全部接口</a>
<a class="mdl-navigation__link" href="https://api.lailal.cc/music-api.html">音乐接口</a>
<a class="mdl-navigation__link" href="https://api.lailal.cc/tv-api.html">视频接口</a>
<a class="mdl-navigation__link" >鸣谢:狐狸</a>
<a class="mdl-navigation__link" >鸣谢:小航</a>
<a class="mdl-navigation__link" >鸣谢:苏禾</a>
<a class="mdl-navigation__link" >等待添加</a>
<a class="mdl-navigation__link" href="https://api.lailal.cc/">戳我添加⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄</a>
</nav>
</div>
<main class="mdl-layout__content">
<div class="page-content">
<!--api.lailal.cc一言-->
</br></br></br></br></br></br></br></br></br>
<span style="font-size:36px"><font color="#FF00FF"><center>A P I 助手管家</center></span>
</br></br>
<span style="font-size:18px"><font color="#FFF100"><center><script type="text/javascript" src="https://api.lailal.cc/hitokoto/?code=js"></script>
<script>kfanghitokoto()</script></center></font></span>
</div>
</div>
</main>
</div>


<!--版权信息-->
<span id="showsectime" style="color:#F0F8FF"></span>
<script type="text/javascript">
function NewDate(str) {
str = str.split('-');
var date = new Date();
date.setUTCFullYear(str[0], str[1] - 1, str[2]);
date.setUTCHours(0, 0, 0, 0);
return date;
}
function showsectime() {
var birthDay =NewDate("2018-09-30");
var today=new Date();
var timeold=today.getTime()-birthDay.getTime();
var sectimeold=timeold/1000
var secondsold=Math.floor(sectimeold);
var msPerDay=24*60*60*1000; var e_daysold=timeold/msPerDay;
var daysold=Math.floor(e_daysold);
var e_hrsold=(daysold-e_daysold)*-24;
var hrsold=Math.floor(e_hrsold);
var e_minsold=(hrsold-e_hrsold)*-60;
var minsold=Math.floor((hrsold-e_hrsold)*-60); var seconds=Math.floor((minsold-e_minsold)*-60).toString();
document.getElementById("showsectime").innerHTML = "API助手管家已稳定运行"+daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒";
setTimeout(showsectime, 1000);
}showsectime();
</script>
<p id="footer"> 本站服务器及CDN加速由 <a href="https://cloud.lailal.net"title="飞狐云· - 为全球客户提供领先的云计算、大数据、人工智能服务,以及定制化行业解决方案。"> 飞狐云计算 </a>提供全力支持!</p>
<script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1276016085'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s5.cnzz.com/z_stat.php%3Fid%3D1276016085%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"));</script>

<div id="aplayer"></div>
<!--[if IE]>
<script src="js/promise.umd.min.js"></script>
<![endif]-->
<script src="js/fetch.min.js"></script>
<script src="js/jquery.slim.min.js"></script>
<script defer src="js/material.min.js"></script>
<script type="text/javascript" src="js/aplayer.min.js"></script>
<script src="js/sweetalert.min.js"></script>
<script src="js/js.cookie.min.js"></script>
<script>
function fetch163Playlist(playlist_id) {
return new Promise(function (ok, err) {
fetch("https://v1.hitokoto.cn/nm/playlist/" + playlist_id)
.then(function (response) {
return response.json();
})
.then(function (data) {
var arr = [];
data.playlist.tracks.map(function (value) {
arr.push(value.id);
});
return arr;
})
.then(function (ids) {
return fetch163Songs(ids);
})
.then(function (data) {
ok(data);
})
.catch(function (e) {
err(e);
});
})
}

function fetch163Songs(IDS) {
var ids;
switch (typeof IDS) {
case 'number':
ids = [IDS];
break;
case 'object':
if (!Array.isArray(IDS)) {
return new Error("Please enter array or number");
}
ids = IDS;
break;
default:
throw new Error("Please enter array or number");
break;
}
return new Promise(function (ok, err) {
fetch("https://v1.hitokoto.cn/nm/summary/" + ids.join(",") + "?lyric=true&common=true&quick=true")
.then(function (response) {
return response.json();
})
.then(function (data) {
var songs = [];
data.songs.map(function (song) {
songs.push({
name: song.name,
url: song.url,
artist: song.artists.join("/"),
album: song.album.name,
pic: song.album.picture,
lrc: song.lyric
});
});
return songs;
})
.then(function (result) {
ok(result);
})
.catch(function (e) {
err(e);
});
});
}
</script>
</body>
</html>


<!--播放器开始-->
<script>
var _rm = _rm || [];
(function() {
var rm = document.createElement("script");
rm.src = "https://api.lailal.cc/music/random_music.js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(rm, s);
})();
</script>
<!--播放器完毕-->

<body onselectstart="return false;" oncontextmenu="alert('请尊重“God-暗影月狐”劳动成果!谢谢合作。');return false;" onkeydown="if(event.keyCode==27) return false;">
<script type="text/javascript">
document.onmousedown = click;
document.onkeydown = ctrl_key;
function click() {
if (event.button == 2)
{
alert('请尊重“God-暗影月狐”劳动成果!谢谢合作。');
return false;
}
}
function ctrl_key() {
if (event.keyCode == 17) {
window.alert("请尊重“God-暗影月狐”劳动成果!谢谢合作。");
return false;
}

if (event.keyCode == 123) {
alert('请尊重“God-暗影月狐”劳动成果!谢谢合作。!');
return false;
}
}
</script>


满分是10分的话,这篇文章你给几分,您的支持将鼓励我继续创作!