// ==UserScript== // @name Danbooru - Copy Commentary // @author hdk5 // @version 20260313132501 // @namespace https://github.com/hdk5/danbooru.user.js // @homepageURL https://github.com/hdk5/danbooru.user.js // @supportURL https://github.com/hdk5/danbooru.user.js/issues // @downloadURL https://github.com/hdk5/danbooru.user.js/raw/master/dist/copy-commentary.user.js // @updateURL https://github.com/hdk5/danbooru.user.js/raw/master/dist/copy-commentary.user.js // @match *://*.donmai.us/* // @grant GM_addStyle // ==/UserScript== /* globals GM_addStyle $ */ /* eslint-disable no-use-before-define */ const TAG_SCRIPT_SHORTCUTS = [ 'paid_reward_available', 'english_commentary', 'korean_commentary', 'chinese_commentary', 'mixed-language_commentary', 'bilingual_commentary', ]; const CSS = ` .copy-commentary summary { font-weight: bold; } .copy-commentary-query, .copy-commentary-tag-script { display: grid; grid-template-columns: auto 1fr auto; column-gap: 0.5rem; align-items: center; } .copy-commentary-shortcuts, .copy-commentary-tag-script-shortcuts { grid-column: 2 / 3; display: flex; flex-wrap: wrap; column-gap: 0.5rem; } .copy-commentary-status-pending, .copy-commentary-status-processing { color: var(--orange-3); } .copy-commentary-status-success { color: var(--green-3); } .copy-commentary-status-error { color: var(--red-3); } .copy-commentary-results-table { display: inline-block; } .copy-commentary-results-table th, .copy-commentary-results-table td { padding: 0.25rem; vertical-align: middle; } .copy-commentary-col-select, .copy-commentary-cell-select { width: 1%; white-space: nowrap; } .copy-commentary-col-id, .copy-commentary-cell-id { min-width: 1rem; } .copy-commentary-col-status, .copy-commentary-cell-status, .copy-commentary-col-tag-script-status, .copy-commentary-cell-tag-script-status { min-width: 1rem; white-space: nowrap; text-align: center; } .copy-commentary-results-table:has(tbody:empty) { display: none; } .copy-commentary-results-table:has(tbody:empty) + .copy-commentary-actions { display: none; } .copy-commentary-actions { display: block; } `; setTimeout(() => { const $addCommentaryDialog = $('#add-commentary-dialog'); if ($addCommentaryDialog.length === 0) { return; } GM_addStyle(CSS); const postId = $('body').data('post-id'); const $shortcutsWrapper = $('
', { class: 'copy-commentary-shortcuts' }); let defaultQuery = `id:${postId}`; const hasChildren = $('body').data('post-has-children'); if (hasChildren) { const childrenQuery = `parent:${postId}`; defaultQuery = childrenQuery; const $childrenShortcut = $('', { href: '#', text: 'Children', class: 'text-xs mr-2', click: ev => onClickShortcut(ev, childrenQuery), }); $shortcutsWrapper.append($childrenShortcut); } const parentId = $('body').data('post-parent-id'); if (parentId) { const parentQuery = `parent:${parentId}`; if (!hasChildren) { defaultQuery = parentQuery; } const $parentShortcut = $('', { href: '#', text: 'Siblings', class: 'text-xs mr-2', click: ev => onClickShortcut(ev, parentQuery), }); $shortcutsWrapper.append($parentShortcut); } const pixivId = $('body').data('post-pixiv-id'); if (pixivId) { const pixivQuery = `pixiv_id:${pixivId}`; const $pixivShortcut = $('', { href: '#', text: 'Pixiv', class: 'text-xs mr-2', click: ev => onClickShortcut(ev, pixivQuery), }); $shortcutsWrapper.append($pixivShortcut); } const source = $('#post-info-source a:last').attr('href'); const sourceQuery = `source:"${source}"`; const $sourceShortcut = $('', { href: '#', text: 'Source', class: 'text-xs mr-2', click: ev => onClickShortcut(ev, sourceQuery), }); $shortcutsWrapper.append($sourceShortcut); const $copyCommentaryDetails = $('
', { class: 'copy-commentary' }); const $queryWrapper = $('
', { class: 'copy-commentary-query' }); const $queryLabel = $('