AO3: [Wrangling] Paste Tag into Char Field + pad separators for search

Adds a button to fill the tag text in the character field, to search for characters to canonize a rel + Pads common tag separators when actually pasting text into Characters field to fix autocomplete, this allows the names on either side to be recognizable to autocomplete

当前为 2024-09-10 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name     AO3: [Wrangling] Paste Tag into Char Field + pad separators for search
// @description  Adds a button to fill the tag text in the character field, to search for characters to canonize a rel + Pads common tag separators when actually pasting text into Characters field to fix autocomplete, this allows the names on either side to be recognizable to autocomplete
// @version  1.1
// @author   Ebonwing (Main paste script), Derpinaz (char paste modif), NexiDava (Pad Separators for Character Autocomplete)
// @grant    none
// @license  GPL-3.0 <https://www.gnu.org/licenses/gpl.html>
// @match        *://*.archiveofourown.org/tags/*/edit
// @namespace https://greasyfork.org/en/users/1365489-derpinaz
// ==/UserScript==


function copyTagChar(){

  var text = document.getElementById("tag_name");

  var syn = document.getElementById("tag_character_string_autocomplete");

  syn.value = text.value.replace(/(?<=[^\s])[/&|]/g, " $&").replace(/[/&|](?=[^\s])/g, "$& ");

}
(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(/(?<=[^\s])[/&|]/g, " $&").replace(/[/&|](?=[^\s])/g, "$& ");
        document.execCommand("insertText", false, paste);
    });
})();

  const button = document.createElement("button")
  button.type = "button";
  button.innerText = "Copy tag into char field"
  button.addEventListener("click", copyTagChar);
  var chartext = document.getElementById("tag_character_string").parentNode;
  chartext.appendChild(button)