Danbooru

Danbooru (etc...) userscripts

Posted under General

biodude711 said:

I tried installing the script on my PC and it is not working.

Resolved over DM. Script won't work with Greasemonkey. Use something less outdated (Violentmonkey, Tampermonkey).

Very happy to find a solution for the +- removal.
Can confirm that it works very easily using tampermonkey extension, then just click the github link and the install button afterwards on my mac's Chrome and edge. Still trying to figure out a way on my ipad.

Updated

岩戸鈴芽 said:

I was actually unaware of this redirect, here's a bookmarklet you can use to easily copy the stacc URL, similar to the one for Twitter intent IDs. Same disclaimer about using Pixiv in anything other than English applies:

javascript:(() => fetch(location.href.replace("en/users", "stacc/id")).then(r => prompt("stacc URL", r.url)))()

Thanks, I only noticed it now, but that is very helpful!
I had to modify it a bit, since I don't use pixiv in English, and my browser evaluates javascript: URIs differently
Thus, it is better to just first remove "en/" if it is there, and wrap the function in void

javascript:void(()=>fetch(location.href.replace("en/","").replace("users","stacc/id")).then(r=>prompt("stacc URL",r.url)))()

I also ended up making a few for other sites by example:

Misskey:
javascript:void(()=>prompt("misskey URL",document.querySelector("link[rel=alternate]").href))()

Bluesky:
javascript:void(()=>prompt("bsky URL",`https://bsky.app/profile/${document.querySelector("meta[name='twitter:value1']").content}`))()

Inkbunny:
javascript:void(()=>prompt("inkbunny URL",`https://inkbunny.net/user.php?user_id=${new URL(document.querySelector('#watches .title_stealthy_link').href).searchParams.get('user_id')}`))()

FANBOX:
javascript:void(()=>(window.wrappedJSObject||window).eval("fetch(`https://api.fanbox.cc/creator.get?creatorId=${location.host==='www.fanbox.cc'?location.pathname.match(/[\\w-]+/)[0]:location.host.match(/[\\w-]+/)[0]}`).then(r=>r.json()).then(j=>prompt('fanbox URL',`https://www.pixiv.net/fanbox/creator/${j.body.user.userId}`))"))()

Unsure whether someone else also made something similar, but until the site supports it this bookmarklet obtains the original(-ish) file from a Bluesky post as described in issue #5640, instead of the potentially upscaled image.

Note that tools like gallery-dl, at least for now, obtain the latter, wrong file, for example post #7192377:

javascript:void(()=>{
    document.querySelectorAll("meta[property='og:image']").forEach(e => {
        const url = new URL("https://bsky.social/xrpc/com.atproto.sync.getBlob");
        const match = e.content.match(/.+(did:.+)\/(.+)@(.+)/);
        url.searchParams.append("did", match[1]);
        url.searchParams.append("cid", match[2]);
        fetch(url).then(r => r.blob()).then(blob => {
            const ourl = window.URL.createObjectURL(blob);
            const a = document.createElement("a");
            a.href = ourl;
            a.download = `${match[2]}.${match[3]}`;
            a.target = "_blank";
            document.body.appendChild(a);
            a.click();
            document.body.removeChild(a);
            window.URL.revokeObjectURL(ourl);
        });
    });
})()

Not extensively tested so it may break, please let me know if it does.

Edit 1: Now works with multiple images in a post.

Edit 2: Danbooru now fetches the correct image.

Updated

hdk5 said:

I also ended up making a few for other sites by example:

Seems the bsky one got broken overnight, here's the new one:

javascript:void(()=>fetch(`https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=${location.href.match(/profile\/([^/]+)/)[1]}`).then(r=>r.json()).then(j=>prompt("bsky URL",`https://bsky.app/profile/${j.did}`)))()

hdk5 said:

Seems the bsky one got broken overnight, here's the new one:

javascript:void(()=>fetch(`https://bsky.social/xrpc/com.atproto.identity.resolveHandle?handle=${location.href.match(/profile\/([^/]+)/)[1]}`).then(r=>r.json()).then(j=>prompt("bsky URL",`https://bsky.app/profile/${j.did}`)))()

This still works without API call

javascript:void(()=>prompt("bsky URL",`https://bsky.app/profile/${document.querySelector('meta[content^="did:"]').content}`))()
Tap to show scorer list tooltip or favoritor list tooltip on touch device
  • Note: This is just a userscript optimize for touch device.

At the first time, this was just a bug fix for Android System Webview-based browsers that couldn't display a tooltip with a long press like Firefox for Android or Chrome for Android.
Now you can simply tap to show scorer list tooltip or favoritor list tooltip and tap again to navigate to list page.

Show
// ==UserScript==
// @name         Tap to show tooltip
// @version      0.2
// @description  Tap to show scorer list tooltip or favoritor list tooltip on touch device
// @author       Sibyl
// @run-at       document-end
// @match        *://danbooru.donmai.us/*
// @grant        none
// ==/UserScript==

(function() {
    "use strict";

    document.addEventListener('click', event => {
        const a = event.target;
        if (event.target.tagName === "A" && (a.parentElement.classList.contains('post-score') || a.parentElement.classList.contains('post-favcount'))) {
            if (!a.focused) {
                event.preventDefault();
                a.focused = true;
                a.addEventListener("blur", () => {
                    a.focused = false;
                });
            }
        }
    });
})();

Updated

1 5 6 7 8 9