diff --git a/lib/routes/zaobao/util.ts b/lib/routes/zaobao/util.ts index 4de18e3a57ecd8..f2d8edf783626b 100644 --- a/lib/routes/zaobao/util.ts +++ b/lib/routes/zaobao/util.ts @@ -86,16 +86,22 @@ const parseList = async ( const article = await got_ins.get(link); const $1 = load(article.data); - const time = (() => - $1("head script[type='application/json']").text() === '' - ? new Date(JSON.parse($1("head script[type='application/ld+json']").eq(1).text())?.datePublished) // HK - : new Date(Number(JSON.parse($1("head script[type='application/json']").text())?.articleDetails?.created) * 1000))(); // SG + let title, time; + if ($1('#seo-article-page').text() === '') { + // HK + title = $1('h1.article-title').text(); + time = new Date(JSON.parse($1("head script[type='application/ld+json']").eq(1).text())?.datePublished); + } else { + // SG + title = JSON.parse($1('#seo-article-page').text())['@graph'][0]?.headline; + time = new Date(JSON.parse($1('#seo-article-page').text())['@graph'][0]?.datePublished); + } $1('.overlay-microtransaction').remove(); $1('#video-freemium-player').remove(); $1('script').remove(); - let articleBodyNode = $1('.article-content-rawhtml'); + let articleBodyNode = $1('.articleBody'); if (articleBodyNode.length === 0) { // for HK version orderContent($1('.article-body')); @@ -107,8 +113,8 @@ const parseList = async ( const imageDataArray = processImageData($1); return { - // <- for SG version -> for HK version - title: $1('h1', '.content').text().trim() || $1('h1.article-title').text(), + // <- for HK version -> for SG version + title, description: art(path.join(__dirname, 'templates/zaobao.art'), { articleBody, imageDataArray,