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 by voca0831

岩戸鈴芽 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 by ANON TOKYO

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 Tooltip

💡 If you've installed the More Tooltips, this one can be skipped.
⚠ This is a userscript optimized for touchscreen devices.

Originally, this was just a bug fix for Android System WebView-based browsers that couldn’t show tooltips on long press, unlike Firefox or Chrome for Android.
Now, users can simply click to display the voter tooltip or favoritor tooltip and then click again to navigate to the target page.

Install

Updated by Sibyl

💜 Show Favorite Groups Count

💡 If you've installed the More Tooltips, this one can be skipped.

Some users don't like adding posts to their favorites may add them to their favorite groups.
This simple userscript shows how many public favorite groups the current post has been added to.

Install

Updated by Sibyl

A userscript @Sibyl made that shows ratings under post thumbnails next to score. Makes it easier to spot misrated posts without opening the post or loading the post tooltip.

Show
// ==UserScript==
// @name         Show rating under thumbnail
// @namespace    http://tampermonkey.net/
// @version      0.1
// @match        https://*.donmai.us/*
// @grant        none
// ==/UserScript==

(function () {
"use strict";
document.querySelectorAll(".post-preview").forEach(e => {
e.querySelector(".post-votes").insertAdjacentHTML(
"beforeend",
`<span style="color:var(--muted-text-color);" class="text-center whitespace-nowrap align-middle min-w-4">${e
.getAttribute("data-rating")
.toUpperCase()}</span>`
);
});
})();
🌐 Full-width Character Converter

This userscript is designed for users who work with CJK characters. It automatically converts full-width characters to half-width ones (:, ()(), etc.) when searching and doing tag gardening. This helps you avoid manually switching your IME or toggling between full-width and half-width modes.

Install

Updated by Sibyl

hdk5 said:

Userscript for uploading to danbooru.

https://github.com/hdk5/upload-to-danbooru.user.js

Unlike the browser extension, which aims to be lightweight and universal, this one does the opposite by supporting only very few sites and including specific hacks for them.

Supported sites so far are:

  • Fantia (post_content_photo type)
    • Adds the upload button to full-size image page
    • Sends the direct image url with post url as referer
    • Currently almost works with the extension, but danbooru doesn't recognize the referer - which I don't like.
    • The full-size image page still has to be opened manually
  • Fantia (album_image type)
    • Adds the upload button on the image in the article
    • Sends the direct image url with post url as referer
    • Doen't work (and never will) with the extension
  • Fantia (download type)
    • Adds the upload button near the download button (e.g. mp4 video)
    • Sends the direct media url with post url as referer
    • Same as the previous, doen't work with the extension
  • Misskey
    • Adds the upload button to reactions row on each tweet
    • Works with the extension's address bar action, but each tweet has to be opened in new tab - which I am too lazy to do and just don't like
  • Pixiv
    • Adds the upload button on post thumbnails
    • Extension's context menu action uploads only the first image in the set - which I don't like
    • Works with the extension's address bar action, but each post has to be opened in new tab - which I am too lazy to do and just don't like

How is this easier than just using the bookmarklet for suported sites?

1 5 6 7 8 9 10 11 12 13