🏠 Home 

AO3: Incomplete. Continue?

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


Install this script?
  1. // ==UserScript==
  2. // @name AO3: Incomplete. Continue?
  3. // @version 1.0
  4. // @description Checks how long ago incomplete works were last updated and displays a warning if longer than user set time period.
  5. // @author sharkcat
  6. // @namespace https://github.com/sharkcatshark/UserScripts
  7. // @match https://archiveofourown.org/works/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=archiveofourown.org
  9. // @license GNU GPLv3
  10. // ==/UserScript==
  11. // note: months are pr###med at 30 days so worst case, warnings are gonna be off by a couple days here and there
  12. // == START Settings ==
  13. const maxTimeAllowed = 6; // months
  14. // == END Settings ==
  15. const chapters = document.querySelector("dd.chapters").innerText;
  16. // if not matching chapter count
  17. if (chapters.match(/\S+(?=\/)/g)[0] != chapters.match(/(?<=\/)\S+/g)[0]) {
  18. // get dates
  19. const currentDate = new Date();
  20. const lastUpdated = new Date(document.querySelector("dd.status").innerText);
  21. // do maths
  22. const diffTime = currentDate - lastUpdated;
  23. const timeSinceUpdateDays = diffTime / (1000 * 60 * 60 * 24);
  24. const timeSinceUpdateYears = timeSinceUpdateDays / (30 * 12);
  25. const roundedDays = Math.round(timeSinceUpdateDays);
  26. const roundedYears = timeSinceUpdateYears.toFixed(2);
  27. // find date of okay update time
  28. const updateLimit = currentDate.setDate(currentDate.getDate() - (maxTimeAllowed * 30));
  29. // see if warning needed
  30. if (updateLimit > lastUpdated) {
  31. 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?";
  32. const subject = document.querySelector("#inner");
  33. 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>' );
  34. }
  35. }