Danbooru (etc...) userscripts

Posted under General

Is there a CSS that removes the downvote button? I've no need for a function that is both completely useless to me and has been used by other users as a way to "attack" other uploaders.

It also serves as a safety measure so that I don't accidentally press the downvote button (which fortunately hasn't happened yet) when browsing on mobile.

Is there a userscript or CSS that adds a tagbox (with a fully functioning tag autocomplete dropdown menu) into the main upload page without anything uploaded, similarly to the old upload page?

Jisadel said:

Is there a userscript or CSS that adds a tagbox (with a fully functioning tag autocomplete dropdown menu) into the main upload page without anything uploaded, similarly to the old upload page?

Here you go:

Show
// ==UserScript==
// @name        Danbooru - add tag box on /uploads/new
// @version     0.1.1
// @author      imapiekindaguy
// @match       *://*.donmai.us/uploads/new
// @grant       GM_addStyle
// @run-at      document-idle
// ==/UserScript==

GM_addStyle(`
div#c-uploads div#a-new textarea {
  width: 100%;
  max-width: 100%;
  height: 20vh;
}
`);

document.querySelector("div#a-new").insertAdjacentHTML("beforeend", `
<div>
  <div class="flex justify-between">
    <label for="post_tag_string">Tags</label>

    <span data-tag-counter="" data-for="#post_tag_string" class="text-muted text-sm">
      <span class="tag-count"></span>
    </span>
  </div>

  <div class="input text optional post_tag_string"><textarea data-autocomplete="tag-edit" data-shortcut="e" class="text optional ui-autocomplete-input" name="post[tag_string]" id="post_tag_string" autocomplete="off" title="Shortcut is e"></textarea></div>
</div>`
);

Danbooru.Autocomplete.initialize_all();

Updated by ygmdd

imapiekindaguy said:

Here you go:

Show
// ==UserScript==
// @name        Danbooru - add tag box on /uploads/new
// @version     0.1.0
// @author      imapiekindaguy
// @match       *://*.donmai.us/uploads/new
// @grant       GM_addStyle
// @run-at      document-idle
// ==/UserScript==

GM_addStyle(`
div#c-uploads div#a-new textarea {
  width: 100%;
  max-width: 100%;
  height: 20vh;
}
`);

document.querySelector("div#a-new").insertAdjacentHTML("beforeend", `
<div>
  <div class="flex justify-between">
    <label for="post_tag_string">Tags</label>

    <span data-tag-counter="" data-for="#post_tag_string" class="text-muted text-sm">
      <span class="tag-count"></span>
    </span>
  </div>

  <div class="input text optional post_tag_string"><textarea data-autocomplete="tag-edit" data-shortcut="e" class="text optional ui-autocomplete-input" name="post[tag_string]" id="post_tag_string" autocomplete="off" title="Shortcut is e"></textarea></div>
</div>`
);

Although a tag box is added, the autocomplete doesn't seem to function on the added tag box. If there's no way to make it work, then it's alright.

Jisadel said:

Although a tag box is added, the autocomplete doesn't seem to function on the added tag box. If there's no way to make it work, then it's alright.

Oh, sorry about that. Add the line Danbooru.Autocomplete.initialize_all(); to the end of the script.

I was wondering why it just seemed to work for me; I have another script that was enabling autocomplete.

imapiekindaguy said:

Oh, sorry about that. Add the line Danbooru.Autocomplete.initialize_all(); to the end of the script.

I was wondering why it just seemed to work for me; I have another script that was enabling autocomplete.

Nice, the script works! Thank you!

I just finished up with a 'smart canvas' userscript, available here. There's a few images there to show it better, but basically it makes a wrapper for (full size) image posts to ensure they fit in your browser window, which means it'll scale down oversized images just as much as needed to fit, and clicking once will zoom in to 1x scale, clicking again resets scale to initial. It also allows you to pan around, and zoom manually (up to 3x), while retaining image-drag functionality at the initial zoom scale (for my fellow click-and-drag savers).

The inspiration was to essentially have a more seamless version of Eza's Image Glutton, bringing sensible zoom/panning into the post page directly. It'd be great to hear feedback, and I'm open to feature or option requests (I tried to make sure all significant variables are already possible to change as constants at the top of the script, but could make a custom interface for tweaking if enough people are interested).

A heads up: deleted uploads percentage (whether you're using the original script or my edited version from forum #310718) was broken due to 1376f7d. To fix it, all you need to do is change Uploads to Posts in the script. I've edited the aforementioned forum post as well if you just want to turn your brain off and copy-paste the entire thing over your current version.

๐Ÿ” Sticky Search Box

Makes the search box stick to the top of the page.

I only recently realized this is actually a small feature from Danbooru EX. However, this version includes some improvements:

  • Better experience on mobile devices.
  • Fixed the autocomplete dropdown menu.

Install

Updated by Sibyl

Sibyl said:

// ==UserScript==
// @name        Toggle Blacklist
// @namespace   https://danbooru.donmai.us/forum_topics/8502
// @match       *://*.donmai.us/*
// @grant       none
// @version     1.0
// @run-at      document-end
// ==/UserScript==

const hotKey = "alt+b"; // Custom hotkey
Danbooru.Utility.keydown(hotKey, "toggle_blacklist", ()=>{
  const a = document.querySelector("#disable-all-blacklists");
  if (a.style.display === "none") a.nextElementSibling.click();
  else a.click();
});

Sweet, how do I change the hotkey? I trried editing the code but it didn't work. alt+b opens up the bookmark menu on firefox

๐Ÿ“Š Post Source Report

Counts and visualizes the sources of a user's uploads on their profile page.

If you know of any additional sites worth including, feel free to DM me.

You can also customize the tracked sources by editing the code at the beginning of the script.

Install

Updated by Sibyl

๐Ÿ‘ฉโ€๐ŸŽจ Strikethrough for banned artists

commit d38c451
* Limit custom CSS to 40k characters long.

Due to upcoming limitations on the number of characters allowed in custom CSS user settings, embedding banned artist data (over 90 KB) into custom CSS is no longer viable.

Since there's no way to target all banned artists using simple CSS selectors, we still need to fetch the data manually.

The updated script now stores the banned artist data in localStorage instead of custom CSS user settings. As a result, Iโ€™ve moved the updated code here from the custom CSS thread (forum #363012).

You can configure the data update interval and specify which types of elements to style at the beginning of the script.

Install

Updated by Sibyl

1 8 9 10 11 12 13