1. 视频类小工具

1.1 BV号AV号互转工具

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
<div class="kratos-post-content">
<div class="container">
<div class="content">
<div class="title">
<center>
BV号AV号互转工具
</center>
</div>
</div>
<div class="row"></div>
<div class="for-group">
<div class="goo">
<center>
<form action="/index.php">
<input type="text" id="x" name="BV" class="form-control2" placeholder="输入AV/BV号(英文开头)" value="" "="" style="text-align:center">
<button type="button" onclick="return exchange() &amp;&amp; false">转换</button>
</form>
</center>
</div>
</div>
<p id="result"></p>
<script>
'use strict';
const table = [...'fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF'];
const s = [11, 10, 3, 8, 4, 6];
const xor = 177451812;
const add = 8728348608;
const av2bv = (av) => {
let num = NaN;
if (Object.prototype.toString.call(av) === '[object Number]') {num = av;}
else if (Object.prototype.toString.call(av) === '[object String]') {
num = parseInt(av.replace(/[^0-9]/gu, ''));
};
if (isNaN(num) || num <= 0) {
return '你在想桃子?';
};
num = (num ^ xor) + add;
let result = [...'bv1 4 1 7 '];
let i = 0;
while (i < 6) {
result[s[i]] = table[Math.floor(num / 58 ** i) % 58];
i += 1;
};
return result.join('');
};
const bv2av = (bv) => {
let str = '';
if (bv.length === 12) {
str = bv;
} else if (bv.length === 10) {
str = `BV${bv}`;
} else if (bv.length === 9) {
str = `BV1${bv}`;
} else {
return '你在想桃子';
};
if (!str.match(/[Bb][Vv][fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF]{10}/gu)) {
return '你在想桃子';
};
let result = 0;
let i = 0;
while (i < 6) {
result += table.indexOf(str[s[i]]) * 58 ** i;
i += 1;
};
return `av${result - add ^ xor}`;
};
const exchange = () => {
var x = document.getElementById('x').value;
if(x.substring(0,2).toLowerCase()=='bv'){
document.getElementById('x').value = `${bv2av(x)}`;
}else if(x.substring(0,2).toLowerCase()=='av'){
document.getElementById('x').value = `${av2bv(x)}`;
}
};
</script>
</div>