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).
Posted under General
https://update.greasyfork.org/scripts/484162/Danbooru%20tags%20buttons.user.js
Here is my own script for "+" "-" buttons which doesn't use anything besides old plain Javascript and it should work everywhere
Updated
The Miscellaneous Tweaks script's option for adding +/- links is now fixed as well.
Make the search bar whole-page wide and pinned to the top of the page.
If used with BrokenEagle98's PostModeMenu+, also makes the post mode menu wide and pinned as well.
https://github.com/hdk5/danbooru.user.js/blob/master/dist/sticky-search.user.js?raw=1
岩戸鈴芽 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:
gallery-dl
: 1243x2000 https://danbooru.donmai.us/media_assets/18772054javascript: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}`))()
Remade my old Tag Preview userscript for it to be less ugly.
Now it will show all tags with aliases and implications, as well as deprecations and some auto-tags in a more compact tree manner, similar to the way character/copyright implications are shown on posts, with a checkbox for a quicker implication trees removal.
https://github.com/hdk5/danbooru.user.js/blob/master/dist/tag-preview.user.js?raw=1
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.
// ==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
hdk5 said:
Add back recently removed "+ -" links next to tags in tag lists.
https://github.com/hdk5/danbooru.user.js/blob/master/dist/plus-minus.user.js?raw=1
amazing, thanks
Some users like me who don't like to add posts to their favorites may add them to their favorite groups.
This simple userscript can show how many public favorite groups the current post has been added to.
// ==UserScript== // @name Show fav groups count // @version 0.1 // @description Show fav groups count in post infomation column // @author Sibyl // @match *://*.donmai.us/posts/* // @grant none // ==/UserScript== (() => { const HIDE_IF_NO_FAVGROUPS_YET = false; const postId = document.body.dataset["postId"]; if (!postId) return; fetch( "/favorite_groups.json?only=id&limit=100&search%5Bpost_ids_include_all%5D=" + postId ) .then(resp => resp.json()) .then(json => { if (Array.isArray(json)) { let len = json.length; if (len === 0 && HIDE_IF_NO_FAVGROUPS_YET) return; len = len > 100 ? len + "+" : len; document .getElementById("post-info-favorites") ?.insertAdjacentHTML( "afterend", `<li id="post-info-favgroups">Favgroups: <a href="/favorite_groups?search%5Bpost_ids_include_all%5D=${postId}" target="_blank">${len}</a></li>` ); } }); })();
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.
// ==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>` ); }); })();
This is a userscript for CJK character users. It can help you automatically convert full-width characters to half-width (:
→ :
, ()
→ ()
, etc.) when searching and doing tag gardening. This way, you don't have to manually switch the IME or change from full-width mode to half-width mode.
// ==UserScript== // @name Full-width Character Converter // @match https://danbooru.donmai.us/* // @grant none // @version 1.0 // @author Sibyl // @description A user script that automatically converts full-width characters to half-width. // ==/UserScript== function hasFullWidthSearchChar(data) { return ( data && (data.indexOf("\uFF1A") > -1 || data.indexOf("\uFF08") > -1 || data.indexOf("\uFF09") > -1 || data.indexOf("\u201C") > -1 || data.indexOf("\u201D") > -1 || data.indexOf("\u2018") > -1 || data.indexOf("\u2019") > -1 || data.indexOf("\u2014\u2014") > -1) ); } function replaceFullWidthChar(data) { return data .replace(/\uFF1A/g, ":") .replace(/\uFF08/g, "(") .replace(/\uFF09/g, ")") .replace(/\u201C|\u201D/g, '"') .replace(/\u2018|\u2019/g, "'") .replace(/\u2014\u2014/g, "_"); } const contentEditableElements = document.querySelectorAll("input[data-autocomplete='tag-query'], textarea[data-autocomplete='tag-edit']"); contentEditableElements.forEach(el => { el.addEventListener("beforeinput", e => { const { inputType, data, target } = e; const { value, selectionStart, selectionEnd } = target; let beginning = value.slice(0, selectionStart); let ending = value.slice(selectionEnd); console.log(e); if (inputType === "insertFromPaste" && data && hasFullWidthSearchChar(data)) { let newData = replaceFullWidthChar(data); let cursor = beginning.length + newData.length; inputElement.value = beginning + newData + ending; inputElement.selectionStart = inputElement.selectionEnd = cursor; return false; } }); el.addEventListener("input", e => { // data here is null if inputType is insertFromPaste in Windows Chrome. // So we need to replace it in beforeinput event. const { inputType, data, target } = e; const { value, selectionStart, selectionEnd } = target; let beginning = value.slice(0, selectionStart); let ending = value.slice(selectionEnd); if (inputType?.startsWith("insert") && data && hasFullWidthSearchChar(data)) { beginning = beginning.slice(0, -data.length); let newData = replaceFullWidthChar(data); let cursor = beginning.length + newData.length; target.value = beginning + newData + ending; // Android Webview and Chrome for Android has no insertCompositionText inputType. if (inputType === "insertCompositionText") target.hasInsertCompositionText = true; // An extra insertText event will be triggered in Windows Chrome. if (inputType === "insertText" && target.hasInsertCompositionText) { cursor = beginning.length; target.value = beginning + ending; } target.selectionStart = target.selectionEnd = cursor; } }); });
Updated
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?