Skip to content

Instantly share code, notes, and snippets.

@lowteq
Last active January 22, 2023 10:57
Show Gist options
  • Save lowteq/9117001664b7d385c9fa02f37c7ee7d5 to your computer and use it in GitHub Desktop.
Save lowteq/9117001664b7d385c9fa02f37c7ee7d5 to your computer and use it in GitHub Desktop.
tempermonkey script : Serialize and display Danbooru tags
// ==UserScript==
// @name injection tags
// @namespace http://tampermonkey.net/
// @version 0.3
// @description Serialize and display Danbooru tags
// @author lowteq
// @match https://danbooru.donmai.us/posts/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=donmai.us
// @grant none
// ==/UserScript==
(function() {
'use strict';
var tagElements = document.querySelectorAll("li.tag-type-0[data-tag-name]");
var dataTagNames = Array.from(tagElements).map(element => element.getAttribute("data-tag-name"));
var artistElements = document.querySelectorAll("li.tag-type-1[data-tag-name]");
var artistTagNames = Array.from(artistElements).map(element => element.getAttribute("data-tag-name"));
var copyrightElements = document.querySelectorAll("li.tag-type-3[data-tag-name]");
var copyrightTagNames = Array.from(copyrightElements).map(element => element.getAttribute("data-tag-name"));
var characterElements = document.querySelectorAll("li.tag-type-4[data-tag-name]");
var characterTagNames = Array.from(characterElements).map(element => element.getAttribute("data-tag-name"));
var headerTagsString = [...artistTagNames, ...copyrightTagNames, ...characterTagNames].join(",").replace(/_/g, " ");
var dataTagNamesString = dataTagNames.join(',').replace(/_/g, " ");
var content = document.getElementById("content");
content.insertAdjacentHTML("afterbegin", `<div>${headerTagsString}</div></br><div>${dataTagNamesString}</div>`);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment