oh I see what happened. it was about a year ago where I had to rewrite part of the danbooru tag script. I posted the new version to the discord server, but never updated it in this thread. try using this script. if you want real indentations, you can find a .js file on the discord pinned in the #tools=and=software channel.
// ==UserScript==
// @name Copy Tags from Danbooru
// @version 1.2
// @description gets tags from danbooru
// @authors exo (original), tbw (updates)
// @match https://censored.booru.org/index.php?page=post*
// @connect https://danbooru.iqdb.org/*
// @connect https://danbooru.donmai.us/*
// @grant GM_xmlhttpRequest
// @grant GM_openInTab
// @run-at document-end
// ==/UserScript==
var tagsToReplace = ["breasts censored_breasts", "ass censored_ass", "pussy censored_pussy"]; //add tags you want to replace here.
var tagsToAdd = []; //add tags you want to add here.
var tagsToRemove = ["bad_id", "bad_pixiv_id", "censored", "mosaic_censoring", "uncensored", "commentary", "commentary_request", "translated", "translation_request", "annotation_request", "source_request"]; //add tags you want to remove here.
var openOriginal = true; // change this to "var openOriginal = false" if you don't want to open the original image in a new tab. Warning: this will make it harder to notice that iqdb has returned a wrong image with wrong tags.
var iqdbTemplate = "https://danbooru.iqdb.org/?url=";
var clicked = false;
var danbooruURL;
function initialize(){
var imageURL = getImageUrl();
console.log('url is: '+imageURL);
getDanbooruUrl(imageURL);
}
function getImageUrl(){
return document.getElementById("image").src;
}
function getDanbooruUrl(imageUrl){
var iqdbUrl = iqdbTemplate+imageUrl;
var req = GM_xmlhttpRequest({
method: "GET",
url: iqdbUrl,
onload: function(){
console.log("parsing iqdb response");
var parser = new DOMParser();
var response = parser.parseFromString(this.responseText, "text/html");
resultNode = response.getElementById("pages").childNodes[2];
if(resultNode.innerHTML.includes("No relevant matches")){
resultNode = response.getElementById("pages").childNodes[5];
}
danbooruURL = resultNode.getElementsByTagName("a")[0].href;
getDanbooruTags(danbooruURL);
}
});
}
function getDanbooruTags(danbooruURL){
var req = GM_xmlhttpRequest({
method: "GET",
url: danbooruURL,
onload: function(){
console.log("danbooru url: "+danbooruURL);
console.log("parsing danbooru tags");
var parser = new DOMParser();
var response = parser.parseFromString(this.responseText, "text/html");
var tagList = response.getElementById("tag-list");
var copyrightTagList = tagList.querySelector("ul.copyright-tag-list");
var characterTagList = tagList.querySelector("ul.character-tag-list");
var artistTagList = tagList.querySelector("ul.artist-tag-list");
var generalTagList = tagList.querySelector("ul.general-tag-list");
var metaTagList = tagList.querySelector("ul.meta-tag-list");
var copyrightTags = [];
var artistTags = [];
var characterTags = [];
var imageTags = [];
var metaTags = [];
var children = tagList.childNodes;
var tagsNotArray; //getElementsByClassName returns array-like object, but it doesn't have foreach method
if (copyrightTagList != null) {
for (var i = 0; i < copyrightTagList.children.length; i++) {
copyrightTags.push("series:" + copyrightTagList.children[i].getAttribute('data-tag-name'));
}
}
if (characterTagList != null) {
for (var i = 0; i < characterTagList.children.length; i++) {
characterTags.push("character:" + characterTagList.children[i].getAttribute('data-tag-name'));
}
}
if (artistTagList != null) {
for (var i = 0; i < artistTagList.children.length; i++) {
artistTags.push("artist:" + artistTagList.children[i].getAttribute('data-tag-name'));
}
}
if (generalTagList != null) {
for (var i = 0; i < generalTagList.children.length; i++) {
imageTags.push(generalTagList.children[i].getAttribute('data-tag-name'));
}
}
if (metaTagList != null) {
for (var i = 0; i < metaTagList.children.length; i++) {
metaTags.push(metaTagList.children[i].getAttribute('data-tag-name'));
}
}
tags = [copyrightTags, artistTags, characterTags, imageTags, metaTags];
//console.log(tags);
replaceTags(tags);
}});
}
function replaceTags(tags){
console.log("adding tags to page");
var imageTags = tags[3];
for(var i = 0; i < tagsToReplace.length; i++){
var replaced = tagsToReplace[i].substr(0,tagsToReplace[i].indexOf(" "));
var replacement = tagsToReplace[i].substr(tagsToReplace[i].indexOf(" ") + 1);
if(imageTags.indexOf(replaced) != -1){
imageTags[imageTags.indexOf(replaced)] = replacement;
}
}
for(i = 0; i < tagsToRemove.length; i++){
var index = imageTags.indexOf(tagsToRemove[i]);
if(index > -1){
imageTags.splice(index, 1);
}
}
for(i = 0; i < tagsToAdd.length; i++){
imageTags.push(tagsToAdd[i]);
}
//remove tagme type tags
var originalTags = document.getElementById("tags").innerHTML;
originalTags = originalTags.replace("tagme", "");
if (tags[1].length > 0) {
originalTags = originalTags.replace("artist_request", "");
}
if (tags[2].length > 0 || tags[1].length > 0) {
originalTags = originalTags.replace("character_request", "");
}
document.getElementById("tags").innerHTML = originalTags;
//add new tags found
for(i = 0; i < tags.length; i++){
for(var j = 0; j < tags[i].length; j++){
var withSpace = " " + tags[i][j];
document.getElementById("tags").innerHTML += withSpace;
}
}
if(openOriginal){
GM_openInTab(danbooruURL);
}
}
function addButton(){
var separator = document.createTextNode(" | ");
var searchLink = document.createElement("a");
searchLink.innerHTML = "Danbooru tags";
searchLink.href = "#";
links = document.getElementsByTagName("a");
for(var i in links){
if(links[i].innerHTML == "Tag History"){
links[i].parentNode.insertBefore(separator, links[i].nextSibling);
links[i].parentNode.insertBefore(searchLink, links[i].nextSibling.nextSibling);
}
}
searchLink.addEventListener("click", function(){
if(!clicked){
clicked = true;
initialize();
}
});
console.log("added button");
}
addButton();