mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Add ass danmaku
This commit is contained in:
parent
1828036900
commit
217768bd3a
@ -2,13 +2,39 @@
|
||||
{
|
||||
return (settings, resources) =>
|
||||
{
|
||||
class XmlDanmaku
|
||||
class Danmaku
|
||||
{
|
||||
constructor(element)
|
||||
constructor(content, time, type, fontSize, color)
|
||||
{
|
||||
this.pData = element.getAttribute("p");
|
||||
[this.time, this.type, this.fontSize, this.color] = this.pData.split(",");
|
||||
this.content = element.innerText;
|
||||
this.content = content;
|
||||
this.time = time;
|
||||
this.type = type;
|
||||
this.fontSize = fontSize;
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
class XmlDanmaku extends Danmaku
|
||||
{
|
||||
constructor({ content, time, type, fontSize, color, timeStamp, pool, userHash, rowId })
|
||||
{
|
||||
super(content, time, type, fontSize, color);
|
||||
this.timeStamp = timeStamp;
|
||||
this.pool = pool;
|
||||
this.userHash = userHash;
|
||||
this.rowId = rowId;
|
||||
this.pDataArray = [time, type, fontSize, color, timeStamp, pool, userHash, rowId];
|
||||
}
|
||||
text()
|
||||
{
|
||||
const pData = this.pDataArray.join(",");
|
||||
return `<d p="${pData}">${this.content}</d>`;
|
||||
}
|
||||
static parse(element)
|
||||
{
|
||||
const pData = element.getAttribute("p");
|
||||
[time, type, fontSize, color, timeStamp, pool, userHash, rowId] = pData.split(",");
|
||||
const content = element.innerText;
|
||||
return new XmlDanmaku({ content, time, type, fontSize, color, timeStamp, pool, userHash, rowId });
|
||||
}
|
||||
}
|
||||
class XmlDanmakuDocument
|
||||
@ -20,5 +46,18 @@
|
||||
this.danmakus = [...document.querySelectorAll("d[p]")].map(it => new XmlDanmaku(it));
|
||||
}
|
||||
}
|
||||
class AssDanmaku extends Danmaku
|
||||
{
|
||||
constructor({ content, time, type, fontSize, color, typeTag, endTime })
|
||||
{
|
||||
super(content, time, type, fontSize, color);
|
||||
this.typeTag = typeTag;
|
||||
this.endTime = endTime;
|
||||
}
|
||||
text(fontStyles)
|
||||
{
|
||||
return `Dialogue: ${this.time}, ${this.endTime}, ${fontStyles[this.fontSize]}, {${this.typeTag}\\c&H${this.color}&}${this.content}`;
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
||||
Loading…
Reference in New Issue
Block a user