AO3: Incomplete. Continue?

Checks how long ago incomplete works were last updated and displays a warning if longer than user set time period.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name        AO3: Incomplete. Continue?
// @version     1.0
// @description Checks how long ago incomplete works were last updated and displays a warning if longer than user set time period.
// @author      sharkcat
// @namespace   https://github.com/sharkcatshark/UserScripts
// @match       https://archiveofourown.org/works/*
// @icon        https://www.google.com/s2/favicons?sz=64&domain=archiveofourown.org
// @license     GNU GPLv3
// ==/UserScript==

// note: months are presumed at 30 days so worst case, warnings are gonna be off by a couple days here and there

// == START Settings ==

const maxTimeAllowed = 6; // months

// == END Settings ==

const chapters = document.querySelector("dd.chapters").innerText;

// if not matching chapter count
if (chapters.match(/\S+(?=\/)/g)[0] != chapters.match(/(?<=\/)\S+/g)[0]) {
    // get dates
    const currentDate = new Date();
    const lastUpdated = new Date(document.querySelector("dd.status").innerText);

    // do maths
    const diffTime = currentDate - lastUpdated;
    const timeSinceUpdateDays = diffTime / (1000 * 60 * 60 * 24);
    const timeSinceUpdateYears = timeSinceUpdateDays / (30 * 12);
    const roundedDays = Math.round(timeSinceUpdateDays);
    const roundedYears = timeSinceUpdateYears.toFixed(2);

    // find date of okay update time
    const updateLimit = currentDate.setDate(currentDate.getDate() - (maxTimeAllowed * 30));

    // see if warning needed
    if (updateLimit > lastUpdated) {
        const message = "This work is currently marked incomplete and was last updated " + roundedDays + " days or " + roundedYears + " years ago. Are you sure you wish to continue?";

        const subject = document.querySelector("#inner");
        subject.insertAdjacentHTML( 'afterbegin', '<div style="border: 2px solid red; background: #ffb5b5; color: black; padding: 10px 30px; max-width: max-content; margin: 0 auto;">'+ message + '</div>' );
    }
}