// ==UserScript== // @name Extend "AO3: Kudosed and seen history" | Standalone Light/Dark skin toggle // @description Add buttons to Export/Import the script history and settings. Rename+color the confusing Unseen/Seen buttons, and the Title. Referer enhanced "Mark as seen on open" from AO3 only. :: Standalone feature: Light/Dark site skin toggle button. // @author C89sd // @version 1.12 // @match https://archiveofourown.org/* // @grant GM_xmlhttpRequest // @namespace https://greasyfork.org/users/1376767 // @downloadURL none // ==/UserScript== const ENHANCED_SEEN_BUTTONS = true; const ENHANCED_SEEN_TITLE = true; const MARK_SEEN_FROM_AO3_ONLY = true; const SITE_SKINS = [ "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 = [...SITE_SKINS]; // Loop through the const options = skinSelect.querySelectorAll('option'); options.forEach(option => { const optionValue = option.value; const optionText = option.textContent.trim(); if (SITE_SKINS.includes(optionText)) { workSkinIds.push(optionValue); // Remove matched name from unmatchedSkins unmatchedSkins = unmatchedSkins.filter(name => name !== optionText); if (option.selected) { //