Danbooru

Read the rules before proceeding!

Topic: Danbooru (etc...) userscripts

Posted under General

Schrobby

I think userscripts.org will soon be gone for good. It might be a good idea to move the scripts hosted there to an alternative site.

  • ID: 98166
  • Permalink
  • Toks

    Schrobby said:

    I think userscripts.org will soon be gone for good. It might be a good idea to move the scripts hosted there to an alternative site.

    Here's one such site I've heard of: https://greasyfork.org/

  • ID: 98168
  • Permalink
  • Ixendr

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

  • ID: 98373
  • Permalink
  • Toks

    Ixendr said:

    Please add "Danbooru 2 Tweaks & Features" to the list (It's actually different thing than "Danbooru 2 Tweaks").
    forum #9023

    Wrong link, you mean topic #9023

  • ID: 98381
  • Permalink
  • Ixendr

    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/[/b][/quote]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).

  • ID: 98421
  • Permalink
  • Schrobby

    Thanks. Userscripts.org seems to be really done for now.

  • ID: 98751
  • Permalink
  • Laethiel

    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. Replace 9999 with your own user ID.

    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.

    // ==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="/users/9999/edit">Settings</a>';
    navbar.appendChild(newli);
    // ==UserScript==
    // @name            danbooru autofocus Tag Blacklist
    // @match           *://*.donmai.us/users/*/edit
    // @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 by Laethiel

  • ID: 131351
  • Permalink
  • BrokenEagle98

    @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...

  • ID: 131353
  • Permalink
  • Laethiel

    Thanks, BrokenEagle98. I edited the post above, they're working for me in both Firefox and Chrome now.

  • ID: 131355
  • Permalink
  • BrokenEagle98

    Just checked the above, and it works great now. Thanks for the quick fix.

  • ID: 131357
  • Permalink
  • Laethiel

    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';
    })();
  • ID: 131715
  • Permalink
  • Laethiel

    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, and white.

    // ==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 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: 120px;">Image 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 = "Image BG: red";
    	} else if (background == "red") {
    		document.getElementById('image').style.background = "white";
    		myButton.firstChild.data = "Image BG: white";
    	} else {
    		document.getElementById('image').style.background = "black";
    		myButton.firstChild.data = "Image 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.

    Updated by Laethiel

  • ID: 132464
  • Permalink
  • BrokenEagle98

    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);
    

    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.

    Updated by BrokenEagle98

  • ID: 132578
  • Permalink
  • BrokenEagle98

    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.

  • ID: 134451
  • Permalink
  • BrokenEagle98

    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:(confirm("Enable embedded notes?")?$.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!");}}):false);
    

    Disable embedded notes

    javascript:(confirm("Disable embedded notes?")?$.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!");}}):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.

  • ID: 136193
  • Permalink