ao3 secondary char&pairing filter

hides works if chosen tags are late in sequence

< Opinie na ao3 secondary char&pairing filter

Ocena: Dobry - skrypt działa

§
Napisano: 30-09-2023

the script worked, but whenever I applied any sort functions it broke. Could just be user error, but I threw it into ChatGPT and asked it to do what I wanted and this is what it gave me:

// ==UserScript==
// @name AO3 Preferred Pairing Filter
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Filters works based on preferred pairings and characters
// @author asitha
// @match https://archiveofourown.org/*works*
// @grant none
// ==/UserScript==

/* CONFIG */
var preferredPairings = ['Clint Barton/Tony Stark', 'James "Bucky" Barnes/Tony Stark', 'James "Bucky" Barnes/Clint Barton',
'Tony Stark/Stephen Strange', 'Derek Hale/Stiles Stilinski', 'James T. Kirk/Leonard "Bones" McCoy',
'Steve McGarrett/Danny "Danno" Williams', 'Merlin/Gary "Eggsy" Unwin']; // Add your preferred pairings
var preferredCharacters = []; // Add your preferred characters
/* END CONFIG */

function filterWorks() {
$('.workhide').remove(); // Remove any previous filtering

for (var i = 0; i < $('.index .blurb').length; i++) {
var tags = $('.index .blurb ul.tags')[i];
var reltags = $('.relationships', tags).text().split(', ');
var chartags = $('.characters', tags).text().split(', ');

var relmatch = reltags.some(function(tag) {
return preferredPairings.includes(tag);
});

var charmatch = chartags.some(function(tag) {
return preferredCharacters.includes(tag);
});

if (!relmatch && !charmatch) {
var work = $('.index .blurb')[i];
work.style.display = 'none';
var button = document.createElement('div');
button.setAttribute('class', 'workhide');
button.innerHTML = '

This work does not prioritize your preferred tags.
Show Work

';
$(work).after(button);
}
}

$('.showwork').click(function() {
var blurb = $(this).parents('.workhide').prev()[0];
$(blurb).removeAttr('style');
$(this).parents('.workhide').remove();
});
}

(function($) {
$('

Odpowiedz

Zaloguj się, by odpowiedzieć.