Skip to content

Instantly share code, notes, and snippets.

@shtrih
Last active March 25, 2023 20:12
Show Gist options
  • Save shtrih/5413585 to your computer and use it in GitHub Desktop.
Save shtrih/5413585 to your computer and use it in GitHub Desktop.
On the post pages under search field appears as a link "🏷️ Tags". When clicked, will open the block with the reference image and a list of tags. На страницС поста, ΠΏΠΎΠ΄ ΠΏΠΎΠ»Π΅ΠΌ поиска появляСтся ссылка "🏷️ Tags", ΠΏΡ€ΠΈ Π½Π°ΠΆΠ°Ρ‚ΠΈΠΈ Π½Π° ΠΊΠΎΡ‚ΠΎΡ€ΡƒΡŽ, откроСтся Π±Π»ΠΎΠΊ со ссылкой Π½Π° ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅ ΠΈ списком Ρ‚Π΅Π³ΠΎΠ².
// ==UserScript==
// @name Danbooru tags getter
// @namespace https://gist.github.com/shtrih/5413585/
// @version 0.3
// @description On the post pages under search field appears as a link "🏷️ Tags". When clicked, will open the block with the reference image and a list of tags. На страницС поста, ΠΏΠΎΠ΄ ΠΏΠΎΠ»Π΅ΠΌ поиска появляСтся ссылка "🏷️ Tags", ΠΏΡ€ΠΈ Π½Π°ΠΆΠ°Ρ‚ΠΈΠΈ Π½Π° ΠΊΠΎΡ‚ΠΎΡ€ΡƒΡŽ, откроСтся Π±Π»ΠΎΠΊ со ссылкой Π½Π° ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅ ΠΈ списком Ρ‚Π΅Π³ΠΎΠ².
// @match https://danbooru.donmai.us/posts/*
// @match https://aibooru.online/posts/*
// @copyright 2013+, shtrih
// ==/UserScript==
function scriptBody() {
var html = $('<div/>', {
class: "ui-corner-all ui-state-highlight notice notice-pending",
css: {
padding: "10px",
position: "absolute",
top: "90px",
right: "30px",
width: "550px",
"box-shadow": "1px 1px 4px #000",
display: "none",
border: "1px solid var(--post-artist-commentary-container-border-color)",
'border-radius': "3px",
background: "var(--post-artist-commentary-container-background)",
},
title: "Triple-click on a line to select it."
}),
link = $('<a/>', {
text: '🏷️ Tags',
href: '#',
click: function () {
html.fadeToggle();
return false;
},
css: {
'float': 'right'
}
}),
attach_to = $('body'),
tags = $('.image-container').attr('data-tags'),
imagelink = $('.image-container [src]').attr('src'),
negative_tags_regex = /^censored|mosaic_censoring|speech_bubble|commentary_request|bar_censor|metadata_request$/
;
$('#search-box').after(link);
html.append('<code>' + imagelink + '</code><br /><br />')
.append('<code>' + tags + '</code><br /><br />')
// with lodash, without negs
//.append('<code>' + tags.split(' ').filter(w => !negative_tags_regex.test(w)).join(', ') + '</code><br /><br />')
// only negs
.append('<code>' + tags.split(' ').filter(w => negative_tags_regex.test(w)).join(', ') + '</code><br /><br />')
// without lodash, without negs
.append('<code>' + tags.split(' ').filter(w => !negative_tags_regex.test(w)).map(w => w.replaceAll('_', ' ')).join(', ') + '</code><br /><br />')
.appendTo(attach_to);
}
var script = document.createElement('script');
script.textContent = '(' + scriptBody.toString() + ')()';
(document.head || document.documentElement).appendChild(script);
script.parentNode.removeChild(script);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment