From 1f28f00d4c902e76152d75eafff9dbeed9365062 Mon Sep 17 00:00:00 2001 From: kang Date: Fri, 9 Aug 2024 02:00:35 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=8F=99=EC=98=81=EC=83=81=20=EA=B3=BC?= =?UTF-8?q?=EC=A0=9C=20=EB=82=98=ED=83=80=EB=82=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/index.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/services/index.ts b/src/services/index.ts index 2767c57..183c709 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -171,18 +171,33 @@ export const getVideoSubmitted = async ( $('.user_progress tbody tr').length === 0 ? '.user_progress_table tbody tr' : '.user_progress tbody tr' let section = '1' + + // const hasAttendance = $('.user_progress thead th').eq(-1).text().trim() === '출석' + + const attendanceRule = $('.rollbook .blue').text().trim() + const matches = attendanceRule.match(/\[(.*?)\]/g) + const attendanceMark = matches ? matches[0].replace(/\[|\]/g, '') : undefined + return mapElement($(className), (_, el) => { if ($(el.firstChild).attr('rowspan') || $(el.firstChild).hasClass('vmiddle')) { section = $(el.firstChild).text().trim() } - const std = $(el).find('.text-center.hidden-xs.hidden-sm') - const title = std.prev().text().trim() + const title = $(el).find('.text-left').text().trim() const sectionTitle = section + + if (attendanceMark !== undefined) { + const attendance = $(el).find('.text-center').eq(-1).text().trim() + + return { title, hasSubmitted: attendance === attendanceMark, sectionTitle } + } + + const std = $(el).find('.text-center.hidden-xs.hidden-sm') + const requiredTime = std.text().trim() const totalStudyTime = std.next().clone().children().remove().end().text().trim() const hasSubmitted = Number(requiredTime.replace(/:/g, '')) <= Number(totalStudyTime.replace(/:/g, '')) return { title, hasSubmitted, sectionTitle } - }) + }).filter((v): v is Pick => !!v.title) }