// ==UserScript== // @name Extend "AO3: Kudosed and seen history" @Min_ // @description Add Export-Import buttons at the bottom of the page. Rename+color Seen/Unseen buttons and Title. Mark as seen on open from AO3 only. Add a button to quickly toggle between light/dark skins. // @author C89sd // @version 1.10 // @match https://archiveofourown.org/* // @grant GM_xmlhttpRequest // @namespace https://greasyfork.org/users/1376767 // @downloadURL none // ==/UserScript== const MARK_SEEN_FROM_AO3_ONLY = true; const WORK_SKIN_NAMES = [ "Default", "Reversi" ]; // Function to fetch the preferences form, extract the authenticity token, and get the skin_id function getPreferencesForm(user) { // GET the preferences fetch(`https://archiveofourown.org/users/${user}/preferences`, { method: 'GET', headers: { 'Content-Type': 'text/html' } }) .then(response => response.text()) .then(responseText => { const doc = new DOMParser().parseFromString(responseText, 'text/html'); // Extract the authenticity token const authenticity_token = doc.querySelector('input[name="authenticity_token"]')?.value; if (authenticity_token) { // console.log('authenticity_token: ', authenticity_token); // Log the token } else { alert('[userscript:AO3 Toggle Site Skin] Error\n[authenticity_token] not found!'); return; } // Find the
const form = doc.querySelector('form.edit_preference'); if (form) { // console.log('Form:', form); // Log the form // Extract the action URL for the form submission const formAction = form.getAttribute('action'); // console.log('Form Action:', formAction); // Find the element:', skinSelect); // Log the select const workSkinIds = []; let currentSkinId = null; let unmatchedSkins = [...WORK_SKIN_NAMES]; // Loop through the const options = skinSelect.querySelectorAll('option'); options.forEach(option => { const optionValue = option.value; const optionText = option.textContent.trim(); if (WORK_SKIN_NAMES.includes(optionText)) { workSkinIds.push(optionValue); // Remove matched name from unmatchedSkins unmatchedSkins = unmatchedSkins.filter(name => name !== optionText); if (option.selected) { //