Danbooru

Danbooru (etc...) userscripts

Posted under General

Please add "Danbooru 2 Tweaks & Features" to the list (It's actually different thing than "Danbooru 2 Tweaks").
topic #9023
Legacy link, no longer updated but with previous versions: http://userscripts.org:8080/scripts/review/160537
Direct link for newest version: https://raw.githubusercontent.com/Lightforger/danbooru-userscript/master/danbooru_tweaks&features.user.js
https://github.com/Lightforger/danbooru-userscript/

I would also recommend the developers of other scripts to move/mirror their scripts somewhere else than userscripts.org:8080.
http://wiki.greasespot.net/User_Script_Hosting Here are some alternatives.
If going Github, I'd really recommend using normal GitHub repo rather than Gist. Or at least creating non-anonymous Gist and updating it.

I can also create unofficial Github mirror repo with all the scripts listed here with their full history taken from userscripts.org:8080's "versions" page. Should I do that?

There is also userscripts.org mirror: http://userscripts-mirror.org

Updated

RaisingK said:

Ixendr said:

Please add "Danbooru 2 Tweaks & Features" to the list (It's actually different thing than "Danbooru 2 Tweaks").
topic #9023
Legacy link, no longer updated but with previous versions: http://userscripts.org:8080/scripts/review/160537
Direct link for newest version: https://raw.githubusercontent.com/Lightforger/danbooru-userscript/master/danbooru_tweaks&features.user.js
https://github.com/Lightforger/danbooru-userscript/

Userscripts.org:8080 version is v 1.0.10.
Current Github version is v 1.0.12 and it has some bugfixes.

I think it's safe to assume that Userscripts.org:8080 version is no longer maintained.
The most valid link would be the last one (it points to project page on Github).

I threw together a couple of little userscripts to facilitate blacklisting. Not worthy of about:userscripts, but here they are just in case they might help anyone else.

The first one adds a link to Settings at the end of the navbar at the top, after "More »". The second one autofocuses the Blacklisted tags textarea on the Settings page.

EDIT: Incorporated BrokenEagle98's suggestions. Should work in both Firefox and Chrome now.
EDIT 2: Changed to the new Settings page link (both UserScripts need to be updated, as the link in the first one and @ match in the second one are changed).

// ==UserScript==
// @name            Danbooru - add Settings link to navbar
// @description     Adds a link to My Account -> Settings in the navbar
// @match           *://*.donmai.us/*
// ==/UserScript==

var navbar = document.querySelector('.main');
var newli = document.createElement('li');
newli.innerHTML = '<a href="/settings">Settings</a>';
navbar.appendChild(newli);
// ==UserScript==
// @name            danbooru autofocus Tag Blacklist
// @match        https://danbooru.donmai.us/settings
// @grant           none
// @run-at          document-idle
// @description     Autofocus the Blacklisted tags textarea of the Settings page on danbooru
// ==/UserScript==

(function(){
	'use strict';
	$('#user_blacklisted_tags').focus();
})();

Updated

@Laethiel

Just for reference, you can use wildcards with the @ match property instead of @ include. See the following for examples...

// @match        *://*.donmai.us/*
// @match        *://*.donmai.us/users/*/edit

For the above, it's not strictly required to put in the account number since there is only one users settings page you can visit... namely you're own.

Also don't know why, but TamperMonkey was throwing fits with your second Javascript example, complaining about the 'use strict'; and that "$" on the second to last line is undefined. It also threw a "Cannot read property 'addEventListener' of undefined" error in the Javascript console (F12).

Using Chrome 58 with all of the above...

Another little userscript, this one defaults to Original artist's commentary instead of Translated commentary. Should work in both Chrome and Firefox.

// ==UserScript==
// @name			danbooru default to Original commentary
// @match        *://*.donmai.us/posts/*
// @grant			none
// @run-at          document-idle
// @description  default to Original commentary instead of Translated commentary on danbooru posts
// ==/UserScript==

(function(){
'use strict';
    $('#commentary-sections > li:nth-child(2)').removeClass('active');
	$('#commentary-sections > li:nth-child(1)').addClass('active');
    var origcomm = document.getElementById('original-artist-commentary');
    origcomm.style.display = 'block';
    var transcomm = document.getElementById('translated-artist-commentary');
    transcomm.style.display = 'none';
})();

This userscript lets you check for transparency surprises, e.g. in post #2640759. It adds a button at the end of the navbar that toggles the color of the background (only behind the image) between black, red, white, and a user-defined default background color (change the value of defBackgroundColor).

// ==UserScript==
// @name			danbooru image background color toggle
// @match		*://*.donmai.us/posts/*
// @grant	   none
// @run-at		  document-idle
// @description  Add a button to toggle the image background color (for seeing images with transparency tricks)
// ==/UserScript==

var defBackgroundColor = "#1B1B1B";
var navbar = document.querySelector('.main');
var newli = document.createElement('li');
newli.innerHTML = '<button id="colorToggleButton" type="button" style="background-color: #F5F5FF; color: #0073ff; border: 1px solid #0073ff; width: 60px;">BG: def.</button>';
navbar.appendChild(newli);

document.getElementById ("colorToggleButton").addEventListener (
	"click", ButtonClickAction, false
);


function ButtonClickAction (zEvent) {
	var background = document.getElementById('image').style.backgroundColor;
	var myButton = document.getElementById('colorToggleButton');
	if (background == "black") {
		document.getElementById('image').style.background = "red";
		myButton.firstChild.data = "BG: red";
	} else if (background == "red") {
		document.getElementById('image').style.background = "white";
		myButton.firstChild.data = "BG: white";
	} else if (background == "white") {
        document.getElementById('image').style.background = defBackgroundColor;
		myButton.firstChild.data = "BG: def.";
	} else {
		document.getElementById('image').style.background = "black";
		myButton.firstChild.data = "BG: black";
	}
}

Alternatively, as OOZ662 comments on that post, you can see these with a bookmarklet. All credit for the bookmarklet goes to OOZ662:

OOZ662 said:

javascript:document.getElementById("image").style.backgroundColor="red";void(0)

EDIT: Styled the button so it doesn't stick out so much. Also added three-way color switch (black->red->white), since certain background colors may not work well with certain images. Also made the button display the current image background color: starts as default (normally white), then cycles through black->red->white. EDIT2: Added user-defined default background color as a fourth part of the cycle.

Updated

I find myself wanting to go to a particular post on Pixiv a lot, and typing out the full URL each time can get to be a chore. I created the following "Bookmarklet" to help with that. It can also be modified to work with practically any other structured site.

Pixiv
javascript:postid=prompt("Enter the ID of the post to go to:");(postid!==null?(location.href='https://www.pixiv.net/member_illust.php?mode=medium&illust_id='+postid):false);
Twitter
javascript:postid=prompt("Enter the ID of the post to go to:");(postid!==null?(location.href='https://twitter.com/nothing/status/'+postid):false);
Nicoseiga
javascript:postid=prompt("Enter the ID of the post to go to:");(postid!==null?(location.href='http://seiga.nicovideo.jp/seiga/im'+postid):false);
Deviantart
javascript:postid=prompt("Enter the ID of the post to go to:");(postid!==null?(location.href='https://www.deviantart.com/deviation/'+postid):false);
Pawoo
javascript:postid=prompt("Enter the ID of the post to go to:");(postid!==null?(location.href='https://pawoo.net/web/statuses/'+postid):false);
Nijie
javascript:postid=prompt("Enter the ID of the post to go to:");(postid!==null?(location.href='https://nijie.info/view.php?id='+postid):false);

Note: Unfortunately, DText doesn't allow one to create a link out of the above, so the bookmarklet will have to be set manually.

Edit:
  • (2017-07-11)
    • Added a couple other common sites.
  • (2017-08-06)
    • Fixed style of note below the bookmarklets.
  • (2018-04-06)
    • Added Deviantart, Pawoo and Nijie

Updated

Sometimes I find myself wanting to use the left and right arrow keys for scrolling instead going to the next or previous pages, most often when there is a very wide DText table. The following bookmarklet fixes that, although it must be applied on each page you want to use the arrow keys on. Also of note, "A" and "D" will still work for page navigation.

javascript:$(document).off("keydown.danbooru.next_page");$(document).off("keydown.danbooru.prev_page");Danbooru.keydown("d", "next_page", Danbooru.Paginator.next_page);Danbooru.keydown("a", "prev_page", Danbooru.Paginator.prev_page);

Note: Unfortunately, DText doesn't allow one to create a link out of the above, so the bookmarklet will have to be set manually.

With the removal of embedded notes from the edit tab, the following bookmarklets will continue to allow the enabling and disabling of embedded notes.

Enable embedded notes

javascript:var conf=confirm("Enable embedded notes?");if (conf){var temp=$.ajax({type:"PUT",url:"/posts/"+Danbooru.meta("post-id")+".json",data:{'post':{"has_embedded_notes":true}},success:(data)=>{Danbooru.notice("Settings updated.");window.location=window.location;},error:(data)=>{Danbooru.notice("Error updating settings!");}});};

Disable embedded notes

javascript:var conf=confirm("Disable embedded notes?");if (conf){var temp=$.ajax({type:"PUT",url:"/posts/"+Danbooru.meta("post-id")+".json",data:{'post':{"has_embedded_notes":false}},success:(data)=>{Danbooru.notice("Settings updated.");window.location=window.location;},error:(data)=>{Danbooru.notice("Error updating settings!");}});};

Note: Unfortunately, DText doesn't allow one to create a link out of the above, so the bookmarklet will have to be set manually.

Edit:
  • (2017-12-02)

Updated

1 2 3 4 5 6 9