Skip to content

Commit 4e9efa9

Browse files
committed
Merge branch 'myfreeer-master'
2 parents adf7525 + 3ca4125 commit 4e9efa9

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/parsers/BilibiliFormat.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ function BilibiliParser(xmlDoc, text, warn){
99
return string.replace(/\t/,"\\t");
1010
}
1111

12+
function formatmode7(text) {
13+
if (text.charAt(0) == '[') switch (text.charAt(text.length - 1)) {
14+
case ']':
15+
return text;
16+
case '"':
17+
return text + ']';
18+
case ',':
19+
return text.substring(0, text.length - 1) + '"]';
20+
default:
21+
return formatmode7(text.substring(0, text.length - 1));
22+
};
23+
if (text.charAt(0) !== '[') return text;
24+
};
25+
1226
if(xmlDoc !== null){
1327
var elems = xmlDoc.getElementsByTagName('d');
1428
}else{
@@ -56,7 +70,7 @@ function BilibiliParser(xmlDoc, text, warn){
5670
}else{
5771
if(obj.mode == 7){
5872
try{
59-
adv = JSON.parse(format(text));
73+
adv = JSON.parse(format(formatmode7(text)));
6074
obj.shadow = true;
6175
obj.x = parseFloat(adv[0]);
6276
obj.y = parseFloat(adv[1]);

0 commit comments

Comments
 (0)