-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
219 lines (209 loc) · 8.37 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="./xlsx.core.min.js"></script>
<title>UIGF格式转换器</title>
</head>
<body>
<h2>1.填写你的UID</h2>
<input type="text" id="uid" placeholder="请输入你的uid">
<h2>2.1.选择非小酋导出的excel文件</h2>
<input type="file" id="feixiaoqiu"/>
<h4>注:非小酋版本无法区分角色祈愿1、2</h4>
<h2>2.2.选择genshin-wish-export导出的excel文件</h2>
<input type="file" id="genshinwishexport"/>
<h4>注:genshin-wish-export版本没有抽卡id,会留空</h4>
<!--<h2>2.3.选择genshin-wish-export转换的json</h2>
<input type="file" id="genshinwishexportjson"/>
<h4>注:无需填写uid,但其缺少抽卡id,会留空和无法区分角色祈愿1、2</h4>-->
<h3>3.1.点击下载uigfv2.2版本的json文件</h3>
<input type="button" onclick="exportUIGFV2D2()" value="下载">
</body>
</html>
<script>
Date.prototype.format = function(fmt) {
var o = {
"M+" : this.getMonth()+1, //月份
"d+" : this.getDate(), //日
"h+" : this.getHours(), //小时
"m+" : this.getMinutes(), //分
"s+" : this.getSeconds(), //秒
"q+" : Math.floor((this.getMonth()+3)/3), //季度
"S" : this.getMilliseconds() //毫秒
};
if(/(y+)/.test(fmt)) {
fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
}
for(var k in o) {
if(new RegExp("("+ k +")").test(fmt)){
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
}
}
return fmt;
}
</script>
<script>
var data;
//非小酋读取部分
document.querySelector('#feixiaoqiu').onchange = function (e) {
let file = e.target.files[0];
readWorkbookFromLocalFile(file, function (workbook) {
feixiaoqiutoObject(workbook);
});
}
//非小酋读取部分
document.querySelector('#genshinwishexport').onchange = function (e) {
let file = e.target.files[0];
readWorkbookFromLocalFile(file, function (workbook) {
genshinwishexporttoObject(workbook);
});
}
// 读取本地excel文件,读取Excel文件对象
function readWorkbookFromLocalFile(file, callback) {
var reader = new FileReader();
reader.onload = function (e) {
var data = e.target.result;
var workbook = XLSX.read(data, {type: 'binary'});
console.log(workbook);
if (callback) callback(workbook);
};
reader.readAsBinaryString(file);
}
function feixiaoqiutoObject(workbook) {
data = new Object();
data.info = new Object();
data.info.uid = document.getElementById("uid").value;
data.info.lang = "zh-cn";
// data.info.export_timestamp = workbook.Props.CreatedDate.valueOf()/1000;
data.info.export_time = workbook.Props.CreatedDate.format("yyyy-MM-dd hh:mm:ss")
data.info.export_app = "非小酋";
data.info.export_app_version = "1.0.0";
data.info.uigf_version = "v2.2";
//创建list数组
data.list = new Array();
//常驻祈愿
var worksheet = workbook.Sheets['常驻祈愿'];
var csv = XLSX.utils.sheet_to_csv(worksheet);
data.list = data.list.concat(feixiaoqiuSheets(csv, 200));
//角色活动祈愿
var worksheet = workbook.Sheets['角色活动祈愿'];
var csv = XLSX.utils.sheet_to_csv(worksheet);
data.list = data.list.concat(feixiaoqiuSheets(csv, 301));
//武器活动祈愿
var worksheet = workbook.Sheets['武器活动祈愿'];
var csv = XLSX.utils.sheet_to_csv(worksheet);
data.list = data.list.concat(feixiaoqiuSheets(csv, 302));
//新手祈愿
var worksheet = workbook.Sheets['新手祈愿'];
var csv = XLSX.utils.sheet_to_csv(worksheet);
data.list = data.list.concat(feixiaoqiuSheets(csv, 100));
console.log(data);
}
function genshinwishexporttoObject(workbook){
data = new Object();
data.info = new Object();
data.info.uid = document.getElementById("uid").value;
data.info.lang = "zh-cn";
// data.info.export_timestamp = (workbook.Props.CreatedDate.valueOf())/1000;
data.info.export_time = workbook.Props.CreatedDate.format("yyyy-MM-dd hh:mm:ss")
data.info.export_app = "genshin-wish-export";
data.info.export_app_version = "1.0.0";
data.info.uigf_version = "v2.2";
//创建list数组
data.list = new Array();
//常驻祈愿
var worksheet = workbook.Sheets['常驻祈愿'];
var csv = XLSX.utils.sheet_to_csv(worksheet);
data.list = data.list.concat(genshinwishexportSheets(csv, 200));
//角色活动祈愿
var worksheet = workbook.Sheets['角色活动祈愿'];
var csv = XLSX.utils.sheet_to_csv(worksheet);
data.list = data.list.concat(genshinwishexportSheets(csv, 301));
//武器活动祈愿
var worksheet = workbook.Sheets['武器活动祈愿'];
var csv = XLSX.utils.sheet_to_csv(worksheet);
data.list = data.list.concat(genshinwishexportSheets(csv, 302));
//新手祈愿
var worksheet = workbook.Sheets['新手祈愿'];
var csv = XLSX.utils.sheet_to_csv(worksheet);
data.list = data.list.concat(genshinwishexportSheets(csv, 100));
console.log(data);
}
function feixiaoqiuSheets(csv, uigf_gacha_type) {
var list = new Array();
var rows = csv.split('\n');
//删除最后一行空行
rows.pop();
//删除第一行标题
rows.shift();
rows.forEach(v => {
var columns = v.split(',');
var obj = new Object();
obj.uigf_gacha_type = uigf_gacha_type+"";
obj.gacha_type = uigf_gacha_type+"";
obj.item_id = "";
obj.count = "1";
obj.time = columns[0];
obj.name = columns[1];
obj.item_type = columns[2];
obj.rank_type = columns[3];
obj.id = columns[6];
list.push(obj);
})
return list;
}
function genshinwishexportSheets(csv, uigf_gacha_type) {
var list = new Array();
var rows = csv.split('\n');
//删除最后一行空行
rows.pop();
//删除第一行标题
rows.shift();
rows.forEach(v => {
var columns = v.split(',');
var obj = new Object();
obj.uigf_gacha_type = uigf_gacha_type+"";
obj.item_id = "";
obj.count = "1";
obj.time = columns[0];
obj.name = columns[1];
obj.item_type = columns[2];
obj.rank_type = columns[3];
obj.id = "";
if(columns[6]=="祈愿2"){
obj.gacha_type=(400+"");
}
else{
obj.gacha_type = uigf_gacha_type+"";
}
list.push(obj);
})
return list;
}
function exportUIGFV2D2() {
const blob = new Blob([JSON.stringify(data)]);
openDownloadDialog(blob,"uigfv2.2.json");
}
/**
* 通用的打开下载对话框方法,没有测试过具体兼容性
* @param url 下载地址,也可以是一个blob对象,必选
* @param saveName 保存文件名,可选
*/
function openDownloadDialog(url, saveName) {
if (typeof url == 'object' && url instanceof Blob) {
url = URL.createObjectURL(url); // 创建blob地址
}
var aLink = document.createElement('a');
aLink.href = url;
aLink.download = saveName || ''; // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
var event;
if (window.MouseEvent) event = new MouseEvent('click');
else {
event = document.createEvent('MouseEvents');
event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
}
aLink.dispatchEvent(event);
}
</script>