Danbooru

Read the rules before proceeding!

Topic: Danbooru userscript/style + few misc scripts

Posted under General

itsonlyaname

Here are a few scripts i made both for fun and to practice coding.

Danbooru 2 Tweaks & Features (Main script)

http://userscripts.org/scripts/show/160537

Install guide:
(*)Firefox: just click the "install" button in the top-right corner
(*)Opera: Download the script (rightclick install, "save as"), go to Options > tools > Preferences > Advanced > Content > JavaScript options. Select the directory from where you want the scripts to run (any directory with *only* scripts). Optional: change it from '.user.js' to '.js' for faster response times. Opera-only feature.
(*)Chrome: Download the script, go to the address "chrome://extensions" and drag the '.user.js' file onto the page.

A few images showing off the main features ~ Custom style is enabled in all images:
Endless pages (zoomed out)
Settings menu
Pool reading mode (zoomed out)

Current features:

Endless pages
Major feature, as seen in the pictures, just scroll down and more images get added to the page.
*Hard limit of 1000 pages

Custom style
Major feature, compresses a lot of blank space on the page.

Pool browsing/reading mode
Major feature, adds a 'browse' button to pools which allows you to easily read series without having to constantly click 'next' or open 100 tabs (image) .
Note, only limited editing is possible on dynamically generated pages, post if you want a specific tool/option to be added.
Clicking the image to hide notes works, and a shift-click has been added to show/hide the translation boxes.

Vote link confirmation
Vote up/down links are now placed behind a "show votes" button, to avoid mis- or accidental clicks.

Freely Move pool navigation
Adds a setting and a button to move the pools bar either above or below the image at the click of a button.

GUI setting
Settings menu - no longer required to browse folders or edit files to change your settings.

Quickswitch blacklist (default: disabled)
Adds a button to toggle an additional set of blacklisted tags. Includes content on the current page.
Default use: SFW mode, hides all explicit/questionable content.
Shift+click to edit the blacklist.

Requests
Feel free to post any requests/suggestions for features, tweaks or changes within the script.




Manual editing of settings
While this is no longer needed due to the settings menu found at the 'my account' page, you can still edit the settings this way if you prefer. (be sure to read the comments above the settings)
(*)Firefox: Tools > Greasemonkey > Manage User Scripts, "options" on the script > Edit this User Script (select notepad, notepad++ or any other text exitor).
(*)Opera: Go to your userscripts folder, rightclick, open with any text editor
(*)Chrome: A bit more complicated, the script is saved in C:\Users\XXXXXX\appdata\Local\Google\Chrome\User Data\Default\Extensions\xxxxxxxxxxxxxxxxxxxxx\1.0.x_0 , edit the "script.js" with any text editor.



-Planned features-
*See 'to-do/idea list:' at the bottom of the script - changes almost every version.

-Known issues-
*The "show all comments" also unhides all vote up/down links.
*Very old browsers, like firefox 3/4 might be not supported.
*The "show blacklisted images" links do not affect images added by endless pages.
*


Simple scripts:

Unless otherwise noted, these scripts work best as a bookmark, just Ctrl+A from pastebin, paste in the "target" or "link" field of a bookmark, or paste in the address bar. These scripts usually are pretty easy to edit as well, if you have trouble reading the code, just run it through a site like http://jsbeautifier.org/

Visual display of translation status:

http://pastebin.com/raw.php?i=1WjebENc
Upon running the script at any page with image thumbnails (pool/search/popular/etc), it will mark them with a colored border depending on their tags, this should be handy for checking if you tagged an entire pool correctly, finding content to translate or just to check tags.

Dotted red border = 'partially_translated'
Solid red border = 'translation_request' or 'commentary_request'
Dotted Green border = check_translation + either 'translated' or 'commentary'
Solid Green border = 'translated' or 'commentary'
None of the above = No border

*followed kounishin's idea to put borders a level higher.

1-click mark translated:

http://pastebin.com/raw.php?i=aRqtGPEt
Simple script, if on a image page, replaces "translation_request" with "translated", removes "partially_translated" and submits. Code's behind it is a little wonky, but works for now. Best place it somewhere you won't accidentally click :P

Copy notes:

http://pastebin.com/raw.php?i=6jV8Lptp
Not-so-simple script, it must be used as a bookmark, as most browsers cut off text in the adress bar after ~4000 characters.
Mainly used for easily copying notes from pixiv templates, or parent/child posts.
Supports scaling up dimensions of notes based on image size, can copy notes 1-by-1 or all notes at once. Everything should be pretty obvious from the menu that comes up.




Changelog:
2013-04-18 - v1.0.10:
- Updated css

2013-04-18 - v1.0.9:
- Mainly just keeping up with danbooru updates
- Added some basic edit tools for pool browsing mode
- Finished Quickswitch blacklist

2013-03-25 - v1.0.8:
- Bugfix

2013-03-18 - v1.0.7:
- Added Quickswitch blacklist
- Updated css
- Fixed endless pages not activating on homepage.

2013-03-18 - v1.0.6d:
- Small CSS/script adjustments to work with new danbooru layout.

2013-03-18 - v1.0.6b:
- Remove the 'disable hotkeys' feature
- Fix a conflict with at least 1 other userscript
- Big CSS update

2013-03-12 - v1.0.5:
- Fixed note position when browsing at reduced image size (samples)
- Fixed the 'click image to hide notes' feature to browsing mode
- Added a 'Shift click image to show all note translations' feature to browsing mode
- Improved performance of browsing mode.
- Blacklist works on browsing mode now. Note, the script only displays the first blacklisted tag it finds.

2013-03-08 - v1.0.4:
- Added pool browsing mode (aka series reading mode) - major feature
- Updated pool-related code to go along with danbooru update

2013-03-07 - v1.0.3:
- Added settings menu
- Added pool quickswap button
- Cleared some outdated css

2013-03-02 - v1.0.2:
- Added a new paginator for endless pages.
- endless pages on pools now works a lot faster & less bugs.
- few minor bugfixes.

2013-02-28 - v1.0.1:
- Added 'Move pool navigation to top' feature
- Added 'Disable hotkeys' feature
- minor improvements in stylesheet

2013-02-28 - v1.0.0:
- initial release
- merged userscript and stylesheet

Updated by itsonlyaname

  • ID: 84726
  • Permalink
  • kounishin

    The translation-status indicators are an excellent idea; if you don't mind, I think I'll steal it. I don't much care for user scripts personally, but straight CSS is actually all you need: here it is in Stylish format. (I tried to follow up on Pastebin, but it was giving me grief with the captchas.)

    I altered your original to put the borders around the wrapper elements, rather than the actual <img> tags: this means they don't clobber the borders used to indicate pending / flagged / parent / child posts, though it also means the translation-status border is always square rather than adapting to the shape of the preview image. I also didn't bother tagging images with no translation tags.

    (Looking at your original post now, I also misremembered some of the styles. Never mind; it should be obvious how to adapt it. For instance, it occurs to me that it should probably flag check_translation, and maybe commentary/commentary_request as well...)

  • ID: 84825
  • Permalink
  • itsonlyaname

    Added a brand new feature which I'm quite proud of, "Endless pages" :)

    It uses the api to dynamically add images from the following pages onto the current page, just by scrolling to the bottom of the page, no clicking required.
    Currently it only supports basic pool & tag-search pages (other pages are on my to-do list).

    Notes; on pools it sends a api request for every image, looking for documentation on how to use the api's more efficiently.

  • ID: 85164
  • Permalink
  • Toks

    itsonlyaname said:

    Notes; on pools it sends a api request for every image, looking for documentation on how to use the api's more efficiently.

    There doesn't seem to be a more efficient way at the moment, but see Albert's response to this issue:
    https://github.com/r888888888/danbooru/issues/608

    I assume that means he'll be adding a way to grab info on multiple images with one request.

    Edit: Actually, id:1,2,3,4,5 works. I guess he added it already. That should do the trick.

  • ID: 85165
  • Permalink
  • itsonlyaname

    Toks said:
    Edit: Actually, id:1,2,3,4,5 works. I guess he added it already. That should do the trick.

    I tested that just a few hours ago and it didn't work xD
    Time for 1.0.1 :)



    Edit - 1.0.1 is out, 2 minor features that are in demand atm.

    Move pool navigation to top
    Simple user preference, if enabled the pools navigation will be moved to above the image

    Disable hotkeys
    Settings to be able to disable hotkeys on a per-key basis.
    Also includes the ability to fix the currently-broken right-arrow hotkey. (just a typo in Danbooru.Post.initialize_shortcuts)

    Updated by itsonlyaname

  • ID: 85168
  • Permalink
  • itsonlyaname

    Yea, i saw it when the other thread got bumped. I have to admit, it's done in a way that's *a lot* simpler then using the API. Currently it does work better then my endless pages. Once i finish mine, it should be at least on par though.
    I didn't really expect to be the first one to bring this feature either way, this is mainly a project for fun / to learn.

    And, that is only for the endless pages :) The custom CCS is equally unmissable for me.
    Also working on a new feature which should be very nice for pool browsing (think endless pages, but with full-size images :D).
    Also looking into an actual preferences page instead of having to edit the script file.


    On another note, i also found out it is fairly easy to make a script for "find all deleted posts in this pool" or even better "large-scale stripping of all pools from deleted posts", it might be useful to clean up some of the larger pools that have full pages of deleted posts. Estimated ~80,000 deleted posts.



    Update:
    v1.0.2:
    -Added a new paginator for endless pages. - it is below the tags, or on the top-right for pools (only for pools with 4 or more pages)
    -endless pages on pools now works a lot faster & less bugs. (pulls 20 images at once instead of 1)
    -few minor bugfixes, code cleanup, etc.
    -The "fix Right arrow key" also is always active now, no matter what settings (of course, the navigation keys can still be disabled)

    Updated by itsonlyaname

  • ID: 85306
  • Permalink
  • itsonlyaname

    Hellbus said:

    Edit - never mind.

    Now i'm curious :3


    Been a while since the last update but there's a few nice features :)

    Look at this sexy settings menu
    Swap position of pools on the fly


    Changelog:
    2013-03-07 - v1.0.3:
    - Added settings menu, settings can now be controlled from the "my account" page and persist even between version updates
    - Added pool quickswap button, does not reset when going to other pages.
    - Cleared some outdated css
    - Updated the "Visual display of translation status" script, was a few days ago but forgot to mention it, it now has a few more tags, larger borders, and does not wipe the pending/child/parent/flagged border of a post anymore.


    Another new feature is partially finished, but i'm not sure about the layout.
    Pool browsing: when viewing images (full size) it adds a 'browse pool' button before the 'next' links on pools (1 for each 'next'), when browsing, the next pages from the selected pool are automatically added to the screen upon scrolling near the edge. (perfect for reading series)
    The problem, i'm not sure sure where to add them yet;
    *images to the right with comments below?
    *images below eachother, with comments inbetween? (behind a "view comments" button)
    *images below eachother, comments to the right side of the image?

    Updated by itsonlyaname

  • ID: 85636
  • Permalink
  • Hellbus

    itsonlyaname said:

    Now i'm curious :3

    Asked a question then saw that it had already been answered. No secrets of impending doom or anything like that.

  • ID: 85640
  • Permalink
  • itsonlyaname

    Updated;

    2013-03-08 - v1.0.4:
    - Added pool browsing mode (aka series reading mode) - major feature
    - Updated pool-related code to go along with danbooru update
    - general code improvements, removal of outdated css, happens about every update, won't be mentioning this in changelogs again.

    Pool browsing mode is 90%+ finished & ready to use, just a few small issues like it ignoring blacklists.

    I initially thought about making the images go off to the right side, keeping the original look of the side (tags left, comments below, etc) but as most people don't know how to easily scroll to the right (even more so if they want to keep the arrow hotkeys active), i added them to the bottom.
    Ended up making an entire custom layout, which i think worked out pretty well.

    Very satisfied with how easy reading a comic is now.


    Edit; 2013-03-10
    Added "copy notes" script, idea from https://github.com/r888888888/danbooru/issues/720
    See first post for more info.
    It's not 100% noob-proof (eg, if you use the script, refresh, use script again it will create duplicate notes, same if you click "copy all notes" twice) but with the script being so limited in use, i doubt anyone will ever have trouble with it.

    Updated by itsonlyaname

  • ID: 85704
  • Permalink
  • Hellbus

    When I click "edit" on a post I can't see the list of tags, and thus can't actually edit them. I don't see anything in the script settings that seems relevant. When I view the same post on a computer where I haven't installed the script I'm able to see the list. I'm not getting there via a pool (no pool or tag listed in the address bar), so I'm not sure what to do.

    Updated by Hellbus

  • ID: 85822
  • Permalink
  • itsonlyaname

    Hellbus said:

    When I click "edit" on a post I can't see the list of tags, and thus can't actually edit them. I don't see anything in the script settings that seems relevant. When I view the same post on a computer where I haven't installed the script I'm able to see the list. I'm not getting there via a pool (no pool or tag listed in the address bar), so I'm not sure what to do.

    Woops, missed something so obvious >.< *curses at single wrong character*

    Anyway, a new version with that fixed is up ~ and 1.0.5 with some more bugfixes / features is coming in a few hours.



    Edit; Updated, v1.0.5:
    -Fixed note position when browsing at reduced image size (samples)
    -Fixed the 'click image to hide notes' feature to browsing mode
    -Added a 'Shift click image to show all note translations' feature to browsing mode ~ was easy to add.
    -Improved performance of browsing mode.
    -In browsing mode, blacklisted tags are now hidden behind a 'show image' button, and the first blacklisted tag that was found (for performance reasons, the script stops as soon as it finds 1 tag)

    Generally just finishing up the browsing mode feature, it's complete now.
    Chrome was giving me some trouble, wouldn't activate anything besides the CSS (gray background) - had to go to the extensions page, uninstall it, then re-install it. Possibly because i changed on which sites it works (added hijiribe & sonohara.donmai).



    Edit2; Updated, v1.0.6b:
    -Remove the 'disable hotkeys' feature, already customizable enough with them being optional & at wasd now.
    -Fix a conflict with at least 1 other userscript
    -big CSS update


    Edit3; Updated, v1.0.7:
    -Added Quickswitch blacklist - i wanted a "someone else enters the room -> hide all rating:q posts" button :) - with only 2 tags available, tacking 'rating:s' on is expensive, and going all the way to the blacklist takes a while.
    -Updated css
    -fixed endless pages not activating on homepage.

    Updated by itsonlyaname

  • ID: 85831
  • Permalink
  • Alanis the Evoker

    Just updated to 1.0.7, and it's giving me an error when I try to change my UserScript settings:

    Failed to save settings Error details:
    LS_setValue is not a function

    The only change I made to it was to disable the custom CSS via:

    var enable_customCSS=0;

  • ID: 86495
  • Permalink
  • itsonlyaname

    Strange, LS_setValue should be a global function - which browser/version are you using?
    I uploaded 1.0.8, if that doesn't work, try enabling 'var db2_debug' (line 70)? It should give an alert message with more details.

    Ps. it is also possible to disable customCSS via the settings menu now (thus without having to edit the script itself).

  • ID: 86556
  • Permalink
  • Alanis the Evoker

    itsonlyaname said:

    Strange, LS_setValue should be a global function - which browser/version are you using?
    I uploaded 1.0.8, if that doesn't work, try enabling 'var db2_debug' (line 70)? It should give an alert message with more details.

    I'm using Firefox 19.0.2 on Windows, for both this post and the previous one. (I'm also using the same browser/version on a Kubuntu Linux rig, but that one's still running v1.0.6 of this script.) And it looks like v1.0.8 of the script is working.

    Ps. it is also possible to disable customCSS via the settings menu now (thus without having to edit the script itself).

    Blame habit there.

  • ID: 86561
  • Permalink
  • Ixendr

    With current Danbooru version, "endless pages" festure requires changing "/ssd/data/preview/" to "/data/preview/" in source to work.

  • ID: 95430
  • Permalink
  • 1