|
// ==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); |