Greasy Fork

AO3 Bookmarking Records

To keep track of bookmarks. Automatically adds on the current date and most recent chapter of the fic you are reading into the bookmark notes. Used for keeping track of when you last read a fic, and what chapter you were on.

目前为 2022-01-21 提交的版本。查看 最新版本

// ==UserScript==
// @name         AO3 Bookmarking Records
// @namespace   Bairdel AO3 Bookmarking Records
// @description  To keep track of bookmarks. Automatically adds on the current date and most recent chapter of the fic you are reading into the bookmark notes. Used for keeping track of when you last read a fic, and what chapter you were on.
// @version      0.1
// @author       Bairdel
// @include     http*://archiveofourown.org/works*
// @include     http*://www.archiveofourown.org/*works*
// @license     GNU GPLv3
// ==/UserScript==


(function() {
    const divider = "Last Read: "; // the bit at the start of the automatically added text

    // automatically checks the Private Bookmark checkbox. Set to false if you don't want this.
    document.getElementById("bookmark_private").checked = true;

    // keeps any bookmark notes you've made previously. Must be above the "Last Read: ".
    // this updates the date you last read the fic each time.
    var bookmarkNotes = (document.getElementById("bookmark_notes").innerHTML).split(divider)[0];

    // get the current date. should be in local time. you could add HH:MM if you wanted.
    var currdate = new Date();
    var dd = String(currdate.getDate()).padStart(2, '0');
    var mm = String(currdate.getMonth() + 1).padStart(2, '0'); //January is 0
    var yyyy = currdate.getFullYear();

    // change to preferred date format
    var date = dd + '/' + mm + '/' + yyyy;

    // gets the current chapter count. remove the split("/") to keep the /?.
    var lastChapter = document.getElementsByClassName("chapters")[1].innerHTML.split("/")[0];

    // puts it all together. feel free to change this format to whatever you like.
    // first part must always be the divider or a new date will be added each time.
    bookmarkNotes = bookmarkNotes + "Last Read: " + date + "<br>Chapter " + lastChapter;

    // fills in the bookmark notes box.
    document.getElementById("bookmark_notes").innerHTML = bookmarkNotes;
})();