Skip to content

Instantly share code, notes, and snippets.

@junhoyeo
Last active December 10, 2024 08:30
Show Gist options
  • Save junhoyeo/ff979d44466d960298fc39a1773532c9 to your computer and use it in GitHub Desktop.
Save junhoyeo/ff979d44466d960298fc39a1773532c9 to your computer and use it in GitHub Desktop.

방법

  1. 비디오 열고 나서 마우스 우클릭
  2. ‘검사’ 선택, 그러면 개발자도구 열릴 것
  3. 개발자도구의 ‘콘솔’에 위의 코드 삽입. 단, chapterNo 값을 차시에 따라 0101 ~ 0104 로 바꿔서 넣어주세요
  4. 그다음 열린 비디오 창 새로고침하면 끗

작동원리

  • 웹앱은 클라이언트 사이드에서, 1초마다 fn_saveProgress 를 호출해 jwplayer 의 상태, heartbeat 등등을 검증한 뒤에 진행도 값 studySec 을 구합니다.
  • markList라는 변수에 세이브포인트(?) 목록이 있는데, 여기서 하나씩 완료할 때마다 진행도를 백엔드에 저장하는 Ajax 콜(ProgressSave.aspx)을 보내고 있습니다. 여기에는 chapterNo (어떤 회차의 강의인지) 와 currentPosition (얼만큼 진행했는지) 가 포함됩니다.
  • 👉 currentPosition 을 적절히 큰 값(13245) 으로 넣어서 저장하는 콜을 수동으로 때려버리면 진행도가 동영상의 끝으로 저장되게 됩니다. 새로고침하면 - 변경된 값이 저장되면서, 완료로 잘 들어가는 것!!

트러블슈팅

  • 다른 위치에서 로그인 되었습니다 라는 알림만 뜨면, 님 컴이 takeCourseSeq 값이 달라서 그래요. 개발자도구 열고 요소(Elements) 탭에서 takeCourseSeq 로 검색하면, 님의 고유값을 찾을 수 있어요. 이거 넣고 다시 실행해보심 됩니다.
var param = "chapterNo=0101&current_frame_count=1&currentPosition="+ 13245+'&courseCd=HLSC60332&takeCourseSeq=40116154&_'+$.now();
$.get('ProgressSave.aspx',param,function(data){
if(data=="N"){
alert('다른 위치에서 로그인 되었습니다. 학습이 종료되며 로그아웃됩니다.');
top.close();
}
});
@gnujoow
Copy link

gnujoow commented Dec 10, 2024

위 코드를 개선했습니다.
courseCd takeCourseSeq를 url에서 가져올 수 없는 경우 element탭에서 검색후 추가해서 사용하면 됩니다.

(function () {
    // 현재 URL 가져오기
    const url = window.location.href;

    // URLSearchParams 객체를 사용하여 파라미터 추출
    const urlParams = new URLSearchParams(new URL(url).search);

    // 필요한 파라미터 추출
    const chapterNo = urlParams.get("chapterNo");
    const courseCd = urlParams.get("courseCd");
    const takeCourseSeq = urlParams.get("takeCourseSeq");

    // 파라미터 검증
    if (!chapterNo || !courseCd || !takeCourseSeq) {
        alert("필수 파라미터가 누락되었습니다. 요청을 실행할 수 없습니다.");
        console.warn("Missing parameters:", { chapterNo, courseCd, takeCourseSeq });
        return; // 실행 중단
    }

    // 추가 동영상 재생 상태
    const currentFrameCount = 1; // Frame count (static or dynamic)
    const currentPosition = 13245; // Current playback position in seconds

    // 현재 시간을 동적으로 추가
    const timestamp = $.now();

    // Param 생성
    const param = `chapterNo=${chapterNo}&current_frame_count=${currentFrameCount}&currentPosition=${currentPosition}&courseCd=${courseCd}&takeCourseSeq=${takeCourseSeq}&_${timestamp}`;

    console.log("Generated Param:", param);

    // 서버에 요청
    $.get('ProgressSave.aspx', param, function (data) {
        if (data === "N") {
            alert('다른 위치에서 로그인 되었습니다. 학습이 종료되며 로그아웃됩니다.');
            top.close(); // 창 닫기
        } else {
            console.log("Progress saved successfully:", data);
        }
    }).fail(function (xhr, status, error) {
        console.error("Error during progress save:", status, error);
    });
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment