Skip to content

Commit 7d179e7

Browse files
committed
fix(utils): handle title exception in mwb25.09
1 parent 3fe5295 commit 7d179e7

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/common/html_utils.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ export const getMWBSources = (htmlItem: HTMLElement) => {
8888
if (src.length === 0) {
8989
const h3Texts = htmlItem.querySelectorAll('h3');
9090

91+
let songIndex = 0;
92+
9193
for (const h3 of h3Texts) {
9294
let isSong = h3.classList.contains('dc-icon--music');
9395
const part = h3.parentNode.classList.contains('boxContent') === false;
@@ -96,6 +98,10 @@ export const getMWBSources = (htmlItem: HTMLElement) => {
9698
isSong = h3.querySelector('.dc-icon--music') ? true : false;
9799
}
98100

101+
if (isSong) {
102+
songIndex++;
103+
}
104+
99105
if (isSong || part) {
100106
let data = '';
101107

@@ -106,9 +112,28 @@ export const getMWBSources = (htmlItem: HTMLElement) => {
106112
}
107113

108114
src += '@' + data;
109-
const nextElement = h3.nextElementSibling?.querySelector('p');
110-
if (nextElement) {
111-
src += ' ' + nextElement.textContent;
115+
116+
const nextSibling = h3.nextElementSibling;
117+
118+
if (nextSibling) {
119+
const nextElement = nextSibling.querySelector('p');
120+
121+
if (nextElement) {
122+
// handle element exception in mwb25.09
123+
if (isSong && songIndex === 2 && nextSibling.tagName === 'DIV') {
124+
src += '@' + nextElement.textContent;
125+
126+
const tmpSibling = nextSibling.nextElementSibling?.querySelector('p');
127+
128+
if (tmpSibling) {
129+
src += ' ' + tmpSibling.textContent;
130+
}
131+
132+
continue;
133+
}
134+
135+
src += ' ' + nextElement.textContent;
136+
}
112137
}
113138
}
114139
}

0 commit comments

Comments
 (0)