// ==UserScript== // @name AO3: Comment Formatting and Preview // @namespace https://greasyfork.org/en/users/906106-escctrl // @version 1.0 // @description Adds buttons to insert HTML formatting, and shows a live preview box of what the comment will look like // @author escctrl // @license MIT // @match *://*.archiveofourown.org/tags/*/comments* // @match *://*.archiveofourown.org/users/*/inbox* // @match *://*.archiveofourown.org/works/* // @match *://*.archiveofourown.org/comments/* // @match *://*.archiveofourown.org/comments?* // @grant none // @require https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js // @require https://ajax.googleapis.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js // @downloadURL none // ==/UserScript== (function($) { 'use strict'; /********************************************************* GUI CONFIGURATION *********************************************************/ // load storage on page startup var standardmap = new Map(JSON.parse(localStorage.getItem('cmtfmtstandard'))); // only a key: true/false list var custommap = new Map(JSON.parse(localStorage.getItem('cmtfmtcustom'))); // all content we need from user to display & insert what they want // if the background is dark, use the dark UI theme to match let dialogtheme = lightOrDark($('body').css('background-color')) == "dark" ? "ui-darkness" : "base"; // the config dialog container let cfg = document.createElement('div'); cfg.id = 'cmtFmtDialog'; // adding the jQuery stylesheet to style the dialog, and fixing the interferance of AO3's styling $("head").append(``) .prepend(`