AO3: [Wrangling] Pad Separators for Character Autocomplete

Pads common tag separators when pasting text into Characters field to fix autocomplete

目前為 2022-07-16 提交的版本,檢視 最新版本

// ==UserScript==
// @name         AO3: [Wrangling] Pad Separators for Character Autocomplete
// @description  Pads common tag separators when pasting text into Characters field to fix autocomplete
// @version      1.1

// @author       Nexidava
// @namespace    https://gf.qytechs.cn/en/users/725254

// @match        *://*.archiveofourown.org/tags/*/edit
// @grant        none
// @license      GPL-3.0 <https://www.gnu.org/licenses/gpl.html>
// ==/UserScript==

(function() {
    let autocomplete = document.querySelector("input#tag_character_string_autocomplete");
    if (!autocomplete) { return; }

    autocomplete.addEventListener('paste', (event) => {
        event.preventDefault();

        let paste = (event.clipboardData || window.clipboardData).getData('text');
        paste = paste.replace(/(?<=\w)[/&|]/g, " $&").replace(/[/&|](?=\w)/g, "$& ");
        document.execCommand("insertText", false, paste);
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址