Danbooru (etc...) userscripts

Posted under General

I just helped baconmeh2 write a userscript, and then they suggested I reply in this thread, so I list the description of the userscript:

DeviantArt filenames contain a base36-encoded post ID at the end (prefixed with "d"). For example, "15_vaati_icons_by_lavleyart_by_lavleyart_dix7cpg" contains "ix7cpg", which converts to "1144161556" in base10. You can directly access posts via "https://deviantart.com/view/1144161556".

This userscript automatically converts base36 IDs to base10 format URLs, allowing quick access to original posts from saved filenames.

Note: Everything from "-" onward in filenames (such as "-pre") are sample image suffixes and can be ignored.

Install it

📊 Milestone Uploads Report
  • Displays a user's upload milestones on their profile page.
  • Supports milestone lookup for arbitrary tags on post counts page.
  • Notify user when approaching the next upload milestone.

You can customize the milestone numbers, the post threshold for notifications, and the notification message by editing the code at the beginning of the script.

Install

Updated by Sibyl

🆎 DejaVu Sans

This script is useful if your OS or browser lacks Verdana or forcibly aliases it to another font.
DejaVu Sans is a similar-looking open-source alternative to Verdana.

Replaces ’s default font Verdana with DejaVu Sans.
While you could normally change fonts via custom CSS, this script uses the GM_getResourceURL API to load fonts more efficiently.

Install

I personally like Verdana—thanks to user #764362 for recommending a great alternative.

Oh wow, that makes source gardening a lot easier. Previously I would do massive truckloads of source fixes by hand and it was a pain especially for artists who have their entire pages in purple sometimes (cough hara (harayutaka) and one other artist).

hdk5 said:

script to convert xhs commentary to dtext

https://github.com/hdk5/danbooru.user.js/raw/refs/heads/master/dist/xhs-copy-dtext.user.js

Oh thank god, thank you. The touch of making the resulting DText be in a textbox instead is great.

I'm honestly just really floored right now how many of my userscripts are supported on Xiaohongshu, now that I got my account back. That downloader may be more often offline than online, but I'm really glad to be seeing us making the most of it.

Allows deprecated tags to be removed using checkboxes the frequent tags section. I personally find it annoying that deprecated tags can't be added to the frequent tags list. This is useful when gardening deprecated tags on the PC.

To use it, install the script below

https://gist.github.com/shemingwan-wen/6014449fe3162b1000e9b196f3bcf1be/raw/1380e00eb00cc1e33567162f1d07deded06c9a33/deprecated_tags.user.js

Go to settings -> advanced, and add the tags you want as negative tags in the textbox. Once you save your settings, the checkboxes should appear

Updated by shemingwan wen

Is there a Danbooru userscript where you can hover your mouse over an artist tag on the post page, and then a pop-up box appears showing the artist tag's most recent posts?

Basically something that can allow approvers to quickly probe artist tags to detect if the artist has previously deleted AI posts.

quick and dirty userscript that fades out thumbnails on tag script and allows simultaneous tag script + favorite by right-clicking an image. made for my personal workflow, but i guess it doesn't hurt to mirror it here in case someone gets some use out of it.

Code
// ==UserScript==
// @name         Tag Script Fadeout + Fav Hotkey
// @version      1.0
// @description  Tiny tweaks to tag scripting
// @author       https://danbooru.donmai.us/users/1247062
// @match        *://*.donmai.us/posts
// @match        *://*.donmai.us/posts?*
// @grant        GM_addStyle
// ==/UserScript==

var visitedPosts = []

GM_addStyle(`
    .is-tag-scripted {
        opacity: 50%;
    }
`)

$(document).on("danbooru:post-preview-updated", onGalleryMutation)

// with the way danbooru works, we can't just add the class immediately, because
// the element of the post will be overwritten. luckily, there's an event for it.

function onGalleryMutation(_, mut) {
    if(!isTagScriptMode()) return

    document.querySelector(`#post_${mut.id}`).classList.add("is-tag-scripted")
}

function isTagScriptMode() {
    return document.querySelector(`body[data-mode-menu="tag-script"]`) != null
}

function clickHook(event, preview) {
    if(!isTagScriptMode()) return

    // track clicked posts, otherwise we may get a nasty infinite loop.
    // shouldn't matter because our simulated click only happens on right clicks,
    // but i'm not taking any chances.
    let pid = preview.href.match(/[0-9]+/g)[0]
    if(pid == null) return
    if(visitedPosts.includes(pid)) return

    // if right click...
    if(event.button == 2) {
        event.preventDefault()

        // intercept the current tag script, add fav:me, simulate a click to execute the script, then clean up.
        let currentScriptId = "tag-script-" + localStorage.getItem("current_tag_script_id")
        let origScript = localStorage.getItem(currentScriptId)

        if(origScript == null || origScript == undefined) return

        localStorage.setItem(currentScriptId, origScript + " fav:me")
        visitedPosts.push(pid)
        preview.click()
        localStorage.setItem(currentScriptId, origScript)
    }
}

function ctxMenuHook(event) {
    if(isTagScriptMode()) return event.preventDefault()
}

document.querySelectorAll(".post-preview-link").forEach((preview) => {
    preview.addEventListener("auxclick", (e) => {clickHook(e, preview)})
    preview.addEventListener("contextmenu", (e) => {ctxMenuHook(e)})
})

edit: updated to use right click as the favorite hotkey instead.

Updated by wingdings

Placeholder1996 said:

Is there any feasible way to have the upload page visibly warn you when uploading a post from an artist with other posts tagged ai-generated, as happens when the site detects ai-generated metadata? I've had a few posts slip through the cracks because I forgot to check an artist profile before posting AI shit.

I use Translate Pixiv Tags for this (topic #14673). When you hover over the Danbooru artist tag on whatever site you're uploading from, it'll show you the last 3 posts (this can be changed in the settings) that the artist has uploaded. If it finds posts that have either the ai-generated or ai-assisted tags, it adds an AI or +AI icon over the post preview. Unless I know the artist, I usually always check this before uploading to make sure that the artist has some legit uploads.

BrokenEagle98 said:

I use Translate Pixiv Tags for this (topic #14673). When you hover over the Danbooru artist tag on whatever site you're uploading from, it'll show you the last 3 posts (this can be changed in the settings) that the artist has uploaded. If it finds posts that have either the ai-generated or ai-assisted tags, it adds an AI or +AI icon over the post preview. Unless I know the artist, I usually always check this before uploading to make sure that the artist has some legit uploads.

Thanks, this will be very helpful. No worse feeling than seeing something you posted a few hours before flagged for AI.

📕 Fix Xiaohongshu / RedNote Post URL

🗨 This userscript is designed for the PC web client only. It hasn’t been tested in mobile browsers running in desktop mode.

This is a userscript that’s not directly related to , but it’s meant to help some users check the sources of images originally posted on Xiaohongshu (RedNote).

Details

Xiaohongshu is a very closed-off social platform with strict risk control policies regarding external link sharing. For source links without a valid xsec_token (or with an expired one), the site always requires users to scan a QR code with the mobile app.Sometimes, even visiting links containing an invalid xsec_token can trigger weird risk control behavior and get your account forcibly logged out.

This script lets you view Xiaohongshu post sources on the PC web client using only the post ID — no need to open the mobile app. You just need to stay logged in.

💡 Because of the site’s strict risk control policies, the script doesn’t automatically fix bad links. When you reach the QR scan page, just click the “view link” option and wait a few seconds.

Install

BrokenEagle98 said:

I use Translate Pixiv Tags for this (topic #14673). When you hover over the Danbooru artist tag on whatever site you're uploading from, it'll show you the last 3 posts (this can be changed in the settings) that the artist has uploaded. If it finds posts that have either the ai-generated or ai-assisted tags, it adds an AI or +AI icon over the post preview. Unless I know the artist, I usually always check this before uploading to make sure that the artist has some legit uploads.

late reply, but I recently installed this. I don't currently see the danbooru artist tag on Pixiv or Twitter

1 9 10 11 12 13 14 15 16 17