Greasy Fork镜像 还支持 简体中文。

AO3: Incomplete. Continue?

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

  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.  
  12. // note: months are presumed at 30 days so worst case, warnings are gonna be off by a couple days here and there
  13.  
  14. // == START Settings ==
  15.  
  16. const maxTimeAllowed = 6; // months
  17.  
  18. // == END Settings ==
  19.  
  20. const chapters = document.querySelector("dd.chapters").innerText;
  21.  
  22. // if not matching chapter count
  23. if (chapters.match(/\S+(?=\/)/g)[0] != chapters.match(/(?<=\/)\S+/g)[0]) {
  24. // get dates
  25. const currentDate = new Date();
  26. const lastUpdated = new Date(document.querySelector("dd.status").innerText);
  27.  
  28. // do maths
  29. const diffTime = currentDate - lastUpdated;
  30. const timeSinceUpdateDays = diffTime / (1000 * 60 * 60 * 24);
  31. const timeSinceUpdateYears = timeSinceUpdateDays / (30 * 12);
  32. const roundedDays = Math.round(timeSinceUpdateDays);
  33. const roundedYears = timeSinceUpdateYears.toFixed(2);
  34.  
  35. // find date of okay update time
  36. const updateLimit = currentDate.setDate(currentDate.getDate() - (maxTimeAllowed * 30));
  37.  
  38. // see if warning needed
  39. if (updateLimit > lastUpdated) {
  40. 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?";
  41.  
  42. const subject = document.querySelector("#inner");
  43. 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>' );
  44. }
  45. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址