// ==UserScript==
// @name Ellililunch AO3 Bookmark Maker
// @namespace Ellililunch AO3 Bookmark Maker
// @description Modified from "Bairdel AO3 Bookmarking Records" this for automatically add title, author, and summary to the bookmark desciption. This should help with record keeping especially with deleted fics. So I can stop going insane. Also adds read date.
// @version 0.15
// @author Ellililunch
// @match *archiveofourown.org/works/*
// @match *archiveofourown.org/series/*
// @license GNU GPLv3
// @downloadURL none
// ==/UserScript==
// new users - scroll right to the bottom
(function() {
const divider = "Read: "; // the bit at the start of the automatically added text. this can be anything, but will need to follow bookmarkNotes in newBookmarkNotes down at the bottom
// 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 "Read: ".
// this updates the date you last read the fic each time.
var bookmarkNotes = (document.getElementById("bookmark_notes").innerHTML).split(divider)[0];
////////////////////////// customisations ///////////////////////////////// DO NOT WORRY ABOUT
// 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();
var hh = String(currdate.getHours()).padStart(2, '0');
var mins = String(currdate.getMinutes()).padStart(2, '0');
// change to preferred date format
var date;
//date = dd + '/' + mm + '/' + yyyy + " " + hh + ":" + mins;
date = mm + '/' + dd + '/' + yyyy; //this is the USA standard date format
console.log(date);
var author;
var words;
var status;
var title;
var summary;
var series_notes;
var lastChapter;
/*
What should it do?
if story title, author, and info is already there, don't add anything
if there are bookmark notes but no story info, add story info
if it's a series, it should get all the titles + summaries?
i think the class for the series "summary" is notes
so this would be
var series_notes;
series_notes = = document.getElementsByClassName("notes")[0].innerHTML; // series "summary" attempt
*/
// checks if series
var seriesTrue = document.getElementsByClassName("current")[0];
if (seriesTrue != undefined) {
// options for series bookmark notes
title = document.getElementsByTagName("h2")[0].innerHTML.trim();
words = document.getElementsByClassName("stats")[2].getElementsByTagName("dd")[0].textContent;
author = document.querySelectorAll('[rel="author"]')[0].innerHTML.trim(); // fic author
summary = document.getElementsByClassName("series meta group.userstuff")[0].innerHTML; // series notes "summary" attempt
/*var complete = document.getElementsByClassName("stats")[2].getElementsByTagName("dd")[2].textContent;
var updated = document.getElementsByClassName("series meta group")[0].getElementsByTagName("dd")[2].textContent
// var status
if (complete == "No") {
status = "Updated: " + updated;
} else if (complete == "Yes") {
status = "Completed: " + updated;
}*/
} else {
// options for fics
lastChapter = "Chapter " + document.getElementsByClassName("chapters")[1].innerHTML.split("/")[0];
title = document.getElementsByClassName("title heading")[0].innerHTML.trim(); // fic name
words = document.getElementsByClassName("words")[1].innerHTML; // fic wordcount
author = document.querySelectorAll('[rel="author"]')[0].innerHTML.trim(); // fic author
summary = document.getElementsByClassName("summary")[0].innerHTML; // summary attempt
/*// status i.e. Completed: 2020-08-23, Updated: 2022-05-08, Published: 2015-06-29
if (document.getElementsByClassName("status").length != 0) {
// for multichapters
status = document.getElementsByClassName("status")[0].innerHTML + " " + document.getElementsByClassName("status")[1].innerHTML;
} else{
// for single chapter fics
status = document.getElementsByClassName("published")[0].innerHTML + " " + document.getElementsByClassName("published")[1].innerHTML;
}
*/
}
//////////////////// THIS IS THE BIT FOR YOU TO LOOK AT /////////////////////////////////////////////////////////////////////////////////////
// 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.
//
puts the next text on a new line
// options for variables are:
// current date
// current time
// current chapter count of fic / current number of parts in series
// title of fic
// author of fic (note that author "Anonymous" breaks this, but "orphan_account" doesn't
// word count of fic
// status of fic i.e. Completed: 2020-08-23, Updated: 2022-05-08, Published: 2015-06-29
/////// examples //////////
// bookmarkNotes = bookmarkNotes + "
Last Read: " + date + "
Chapter " + lastChapter;
// bookmarkNotes = bookmarkNotes + "
Last Read: " + date + "
Chapter " + lastChapter + "
" + title + " by " + author;
// bookmarkNotes + "
Last Read: " + date + "
" + lastChapter + "
" + title + " by " + author + "
" + status;
// newBookmarkNotes = bookmarkNotes +"
" + title + " by " + author + "
" + summary + "
Read: " + date;
//THIS IS THE NORMAL CODE
//var newBookmarkNotes = title + " by " + author + "
" + summary + "
Read: " + date + "
" + bookmarkNotes;//for new bookmarks
/* ok this is just a section for me to quickly update all my existing bookmarks*/
//var newBookmarkNotes = title + " by " + author + "
" + summary + "
" + bookmarkNotes;
/////////////////SELECT YOU OPTIONS//////////////////////////////
//var newBookmarkNotes = title + " by " + author + "
" + summary + "Read: " + date + "
" + bookmarkNotes; //with current date
var newBookmarkNotes = title + " by " + author + "
" + summary + "
" + bookmarkNotes; //without date for spam making notes
// fills in the bookmark notes box.
document.getElementById("bookmark_notes").innerHTML = newBookmarkNotes;
})();