From 26bd6c47e42e7071645356e3752452c637433637 Mon Sep 17 00:00:00 2001 From: agnes Date: Sun, 14 Jun 2026 22:31:18 +0000 Subject: [PATCH] Add scripts/sunset-morebysameauthor --- scripts/sunset-morebysameauthor | 293 ++++++++++++++++++++++++++++++++ 1 file changed, 293 insertions(+) create mode 100644 scripts/sunset-morebysameauthor diff --git a/scripts/sunset-morebysameauthor b/scripts/sunset-morebysameauthor new file mode 100644 index 0000000..401445f --- /dev/null +++ b/scripts/sunset-morebysameauthor @@ -0,0 +1,293 @@ +// ==UserScript== +// @name sunset author+tags quick-search +// @version 1.2 +// @include https://sunset.femslash.club/works* +// @include https://sunset.femslash.club/chapters* +// @description Generates quick links from Sunset fics to more by the same author in the same fandom (or character/pairing/any other tag). Original code by rallamajoop +// @namespace rallamajoop +// @downloadURL https://update.greasyfork.org/scripts/393481/AO3%20author%2Btags%20quick-search.user.js +// @updateURL https://update.greasyfork.org/scripts/393481/AO3%20author%2Btags%20quick-search.meta.js +// ==/UserScript== + +/* Adds extra links to the tags section at the top of an AO3 work page, redirecting user to any use of same tags by the same author. +* ie. a quick way to find out if the writer of the great fic you just read has written anything else for the same fandom/pairing/trope/etc. + +* If printCounts is set to 'true', code will also calculate and display the number of uses of each tag in the fandom/relationship/character sections. +* This will also make the links take longer to load, as code must pre-load each link individually. To limit load, I have not implemented this for freeform +* or other tags. + +* Author-based search links are a bit of a hack, but most cases should now select correctly in the tags menu on the right. I've added a subheading identifing the tag to cover all bases. +*/ + +//Setting variables! Change these if you like +var printCounts = true; // setting this to false will prevent script for printing tag counts, which may decrease loading times and server load +var quickSearchText = "*"; // text for new links - change this if you want something other than an *. You can put TEXT to make it superscript +var autoSortResultsBy = ""; // valid options are "Kudos", "Word Count", "Date" or "" (none, usually defaults to date) +var importantTags = ["fandom","relationship","character"]; // these are the tags which the script prints counts for + +//Proper code starts here +var loc = location.href; +var href="https://sunset.femslash.club/works?utf8=%E2%9C%93&commit=Sort+and+Filter&work_search"; //[relationship_names]="; +var workPage=["https://sunset.femslash.club/works/", "https:/sunset.femslash.club/chapters/"]; +var scriptTag = "&greasemonkey"; //tag to flag that we've clicked an author quicktag link + +var sortOpts = {"Kudos": "&work_search[sort_column]=kudos_count", "Word Count": "&work_search[sort_column]=word_count", "Date" : "&work_search[sort_column]=revised_at" }; + +if (isWorkPage(loc)) { + // Story page, add extra links user-based search to each tag + + var h3=document.body.getElementsByClassName("byline heading"); + var authors=h3.item(0).getElementsByTagName('a'); + authors=parseAuthors(authors); + + var allTags=document.body.getElementsByClassName("work meta group").item(0); + var dds = allTags.getElementsByTagName('dd'); + + var links = dds.item(1).getElementsByTagName('a'); + + for (var j=0; j=0; i--) { + + for (var a=0; a1) { + text = "(" + count.toString() + ")"; + } + else { + text = "(1)"; + } + } + + var toolTip = "'" + unformatTag(tag) + "' fic by " + author; + newlink.innerHTML = " " + text + ""; + + links.item(i).parentNode.appendChild(newlink); + } + } + } + } +} + + +else if (loc.includes(scriptTag)) { + // Quicktags search results page, add title to show which tag is in use + + //var sTag = getBetween("work_search[relationship_names]=", loc, "&user_id="); + let sTag, tagType; + [tagType, sTag] = parseLoc(loc); + var main = document.getElementById("main"); + var heading = main.getElementsByClassName("heading").item(0); + + sTag = unformatTag(sTag); + + var subTitle = "
Author QuickSearch: " + sTag; + var span=document.createElement('h3'); + span.innerHTML = subTitle; + +// const sortBys = sortLinks(loc); +// heading.parentNode.insertBefore(sortBys, heading.nextSibling); //not really necessary as of v1.2 + heading.parentNode.insertBefore(span, heading.nextSibling); + + checkTagBox(tagType, sTag); +} + +//don't bother counting fics by orphan_account - these won't all be by same author anyway +function ignoreAuthor(author) { + if (author == "orphan_account") return true; + return false; +} + +function getTagType(element) { + var name = element.className; + if (!name.includes(" tags")) return false; + name = name.replace(" tags", ""); + return name; +} + +//True if work or chapter +function isWorkPage(href) { + for (var i=0; i0) { + h=h[0]; + var text = h.textContent; + if (text.includes(" of ")) { + text = getBetween(" of ", text, " Works"); + return text; //could convert this into an integer, but not much point + } + } + return 20; +} + +//May be multiple authors, may have pseudonyms. Returns as array +function parseAuthors(links) { + var authors = [""]; + for (var i=0; i