close
Danbooru Upload Bookmarklet Mk II

I figured I would share this, since it's a useful piece of code (used by スラッシュ and myself so far).

Some time ago I grew tired of how painful it was to upload to danbooru, and the many annoying quirks of the official bookmarklet, including the fact it insists on opening everything in a new window, which is doubly painful if what you upload from happens to be pixiv. Thus I set out to write a replacement that'd actually help with the task.

The current version is available at http://pastebin.com/X9Y5iqEt. To install, copy the entire text from the raw view, then make a new bookmark, putting the text you just copied as the URL (and name it "danbooru upload" for instance). Then to use it, navigate to a page you wish to upload from, and click the bookmarklet.

What it does currently
  • Support uploading directly from non-manga pixiv post page (that is, mode=medium) with no extra clicks. It takes care of resolving the original resolution image, so you don't have to. Obviously if you're already on the big (or manga big) mode page, it will also work.
    • Example
    • Requires you to be logged in
  • Support uploading directly from manga pixiv post page. This is a bit different from other methods, since it has to deal with multiple potential upload targets. To this end, it will wrap each image found in a link to danbooru upload page, and highlight it with a red border. Note that the links do not open in a new window; you're advised to use your middle mouse button to open things in new tabs, like God intended.
    • Caveat: it will only work on images already loaded by Pixiv's stupid JS (which means the ones you've scrolled to already). Trying to work around that idiocy is simply too much work. So if you see an image it has missed (== no red border) that you want to upload, just click the bookmarklet again.
    • Caveat: it does various things, like removing onclick handlers, to elements it manipulates. In general, once you run the bookmarklet, the resulting page is not meant to be consistent with how pixiv does things. It's meant to be convenient for uploading; if you want Genuine Pixiv Experience™, reload the page.
    • Caveat: in order to let you preview the images you upload on the danbooru upload page (exploiting the cache to work around pixiv's referrer checks), it will replace the manga-sample size images with the manga-big ones. This will rape you for a bit of bandwidth, as it has to download the full versions of the images.
    • Example
    • Requires you to be logged in
  • Support uploading directly from TINAMI post pages, just like with pixiv.
    • Example
    • Requires you to be logged in
  • Support uploading directly from Twitpic.
    • Since Twitpic uses Amazon S3 to host images together with their stupid authentication system, which means the URLs expire, and danbooru doesn't support giving separate source and upload URLs, it's a bit less automatic. The source URL as passed to danbooru will have #original-url=... appended. After uploading you need to remove everything up to that point, and leave only the following URL.
    • Example (it's already been uploaded as post #859219, so don't actually upload it. The artist finder gets confused anyway)
  • Support uploading directly from deviantArt. Supports both their sane URLs and the /#/blah style JS idiocy. Like with Twitpic, the original page's URL will be appended to the source image URL.
  • New: Support uploading directly from piapro.jp post pages, similar to pixiv and TINAMI. The same caveat about #original-url applies as with twitpic and dA.
  • Support uploading generic image URLs. If you're currently browsing any image danbooru will accept, you can use the bookmarklet and it'll upload it.
What it doesn't do (yet)
  • Generic HTML uploads. For sites that aren't specifically supported, it'd be possible to do some heuristics to identify what is probably the image you mean to upload. That hasn't been implemented yet.
  • There's no progress indication. Since it does background XHR requests to resolve full image URLs, it might take a second or two before it redirects to the danbooru upload page. Be patient.
  • Support other specific sites. All the development is done on the scratch the itch basis, so if you want me to look at something specifically, say so.

My personal opinion (and スラッシュ's, as he's been my very enthusiastic beta tester) is that it's strictly better than the stock upload bookmarklet. Ideally I'd like to see it become the stock bookmarklet. If you have any comments, opinions, requests, bug reports, etc., please say so. And if you want to see the source (what I pasted above is minified), that can be arranged too.

Changelog

  • 01.03.2011 -- v1.1.1, first public version
  • 06.03.2011 -- v1.2.0, add support for pixiv manga uploads
    • 06.03.2011 -- v1.2.1, make it preserve width/height of the samples when loading full size manga images. It turned out to matter after all.
  • 07.03.2011 -- v1.3.0, add deviantArt support by evazion
    • 07.03.2011 -- v1.3.1, improved dA support
  • 23.03.2011 -- v1.4.0, support for piapro.jp (depends on server-side support from danbooru)
    • 22.06.2011 -- v1.4.1, fix a breakage introduced by recent Chromium / Firefox versions which made RegExp objects non-callable. Apparently breaking existing code is "improving compatibility" now according to browser vendors.

Tested it out and it works good so far. My only issue is that the pixiv translator script doesn't work but it makes it convenient for uploading, especially when it comes to tagging what is in the image without having to swap between tabs.

Yeah this works perfectly. Replace that old shit right now.

Anelaid said:
Tested it out and it works good so far. My only issue is that the pixiv translator script doesn't work but it makes it convenient for uploading, especially when it comes to tagging what is in the image without having to swap between tabs.

Hmm, I'm not exactly sure how it interacts with the translator script and/or tagging and tabs. Care to explain?

The translator script is incompatible, at least, it doesn't translate the notes using this system.

I was saying that the benefit of this system is that I don't have to switch between tabs since I did all of this manually before.

Anelaid said:
The translator script is incompatible, at least, it doesn't translate the notes using this system.

I was saying that the benefit of this system is that I don't have to switch between tabs since I did all of this manually before.

The problem is I don't understand what you're talking about. The code I wrote is a bookmarklet, you have to launch it explicitly before it does anything. I don't see how it could possibly be incompatible with anything in this case.

Similarly, I don't understand how exactly it frees you from switching between tabs. Could you explain what you did before, and what you do now, and where the difference is? If I can understand the workflow you're using, I can do more to support it and/or present it as one example of use I wasn't previously aware of.

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

I use this script to translate the tags for Pixiv and, with this system, the tags are not translated. I know that all of the tags aren't translated by this script as well.

The system I used before was to use the "copy image location" feature on the pixiv image in one tab, paste it in the upload box in the other, and go between the two to examine the picture and tag it appropriately.

With this new system, I can use the special bookmark and it has the upload page and the picture on the same page without having to go between different pages.

Hopefully this is more clear.

Ah, I get it now. Yes, it's not possible for the userscript to work, since the tags you see are fetched and displayed by danbooru, and not pixiv, so the script won't fire It'd have to be updated specifically to support pixiv tags on danbooru (or pixiv tags or any non-pixiv site perhaps). And that's also what's responsible for the fact you have the tags presented alongside the uploaded picture, since unlike with your manual pasting of the URL, danbooru now has enough information to know it's a pixiv upload and so can fetch the tags.

New version posted, see the changelog in the first post.

*tries it out*

Very cool.

v1.2.1, minor fix for manga uploads.

Nice work on the pixiv manga upload system, I wasn't sure there was gonna be a good method for that. This seems to works great though!

Glad to hear that. Do we have any other major sources that could use special support, besides FC2?

And speaking of FC2, what is the typical mode the images are posted there? There's nothing to say there can't be multiple images per post, right? Do you think a hybrid mode which submits the image automatically if there's only one, otherwise falls back to pixiv manga-style borders would be a good approach?

Yeah that's right, there are no limits to the amount of images. I guess you'd have to detect if the image link is likely to be a real piece of art, maybe through a minimum image size? Otherwise I like that idea of adapting the pixiv manga upload style when the script can't figure out what the image you want is. Maybe that can even be a generic fallback method, for example for a site like this http://snt.iiyudana.net/index.html

Yeah, exactly. I was thinking of doing an analysis of images linked and grabbing the most likely one if there is any clearly bigger than the rest, otherwise letting you decide manually. The specific FC2 support would rather have to do with pre-caching, knowing where to look for the actual post HTML (as opposed to ads, sidebars, etc.), and similar.

Does FC2 do anything like rescaling/sampling images? Do the artists do that commonly? Are there any particularly nasty checks in place (I still hate their guts for serving *404*, not 403, upon failed referrer check)?

Nice, I like this script. I had been using a much simpler bookmarklet I wrote that required you to view the bare image to upload. This is much more convenient.

Another thing that might be of use to people in this thread is a userscript (not my work) that I've been using recently that autoloads the original/big image in situ and converts the link to one that runs an IQDB similarity search for that image for you. It also appears to work fine alongside this bookmarklet.

Here's a patch for DeviantArt support: http://pastebin.com/raw.php?i=5BB4ucZi.

It passes the original URL as an URL fragment rather than as an URL query string parameter since I remove the query string entirely from dA URLs (it's not necessary for our purposes).

evazion said:
Here's a patch for DeviantArt support: http://pastebin.com/raw.php?i=5BB4ucZi.

It passes the original URL as an URL fragment rather than as an URL query string parameter since I remove the query string entirely from dA URLs (it's not necessary for our purposes).

Sadly it breaks on their retarded hash URLs (http://www.deviantart.com/#/d3b2a8h), that is, the matcher won't fire, and these are what http://www.deviantart.com/ links to for instance. Care to fix that?

EDIT: nevermind, it was stupidly simple and I did it myself.
EDIT2: Updated the OP with the new version.

Here's an improved version: http://pastebin.com/raw.php?i=gXYB9gyQ.

dA uses at least 3 types of image URLs (that I'm aware of):

This version should work with all of them. It now grabs the original URL from the link beneath the image since that's a http://vinhnyu.deviantart.com/art/Violin-Youmu-187271989 type URL and that's the type we should use for our source URLs.

evazion said:
Here's an improved version: http://pastebin.com/raw.php?i=gXYB9gyQ.

dA uses at least 3 types of image URLs (that I'm aware of):

This version should work with all of them. It now grabs the original URL from the link beneath the image since that's a http://vinhnyu.deviantart.com/art/Violin-Youmu-187271989 type URL and that's the type we should use for our source URLs.

Great, thanks. Updated the OP with the fixed version.

It's doing well. I appreciate your work on this.

I tested this out (but didn't upload) with the violin Youmu Deviantart post. The source URL ended up being:

http://www.deviantart.com/download/187271989/violin_youmu_by_vinhnyu-d33hvzp.jpg#original-url=http://vinhnyu.deviantart.com/art/Violin-Youmu-187271989

First of all, Find Artist did not work with this.

Second of all, is the #original-url= stuff intended to be there along with the direct image link? Am I doing something wrong, or should I just manually cut the source URL down to http://vinhnyu.deviantart.com/art/Violin-Youmu-187271989 which, to my understanding, is how DA sources are to be listed? (Please correct me on that last bit if I'm wrong.)

You're supposed to edit the post and cut the source URL down to http://vinhnyu.deviantart.com/art/Violin-Youmu-187271989 after the post has been uploaded. Once you've done that Find Artist will work.

To use Find Artist on the upload page itself you have to temporarily cut the URL down, hit Find Artist, then use undo to restore the URL before you upload.

The point of this #original-url= business is just to make it a little easier to fix the source URL after uploading. It saves you the trouble of having to go back to dA to copy & paste the original URL.

Is it possible to get the full size from this? http://piapro.jp/t/JGTN

スラッシュ said:
Is it possible to get the full size from this? http://piapro.jp/t/JGTN

It's pretty fucking vile, but I managed to get around most of the nastiness, and I have the bookmarklet code to submit the fullsize URLs now. However, it won't serve any content if you're not logged in, which means danbooru won't be able to retrieve the image until albert adds support for sending appropriate cookies to piapro.

Edit: I've uploaded the version with piapro support and updated the changelog, but it won't be useful until the appropriate Trac ticket is resolved.

Ah, gotcha. Yeah, it's pretty much a monstrosity.

I've created a new track ticket for allowing more URLs to be specified than just the image URLs. That'd allow, amongst other things, the artist finder to work on dA, pipa.jp and others' uploads, and enable us to get rid of the #original-url= hack.

Right now I see at least two extra fields to be specified:

  • "Context", to aid the artist finder to work (and perhaps enable generation of current pixiv-style links, where the actual target is the containing post page).
  • "Override source" boolean flag, which if specified would cause the context to take priority over the actual image URL and make it be recorded as the source. This is necessary for Twitpic, since its URLs expire.

I'd especially appreciate comments from evazion, zatchii, and whoever else writes code against the danbooru API.

Quick note on another subject: after uploading post #887448 using the bookmarklet I got one of those automated messages about pixiv sample images, ie.

You gave this post the source of a pixiv manga sample ( http://img01.pixiv.net/img/u10/17788691_p1.jpg?1301566930 ), but it was actually the full size ( http://img01.pixiv.net/img/u10/17788691_big_p1.jpg?1301566930 )--either it wasn't uploaded from the URL you supplied, or the sample version is identical to the original.

Obviously it doesn't actually matter, but to avoid it, I guess you should always give the big url. Unless there's a reason why it's worked out like that? Not a big deal.

Huh, that's a bug, it should submit the big URL. I don't know why it does that, I'll look into it.

When I use the bookmarklet there is no image shown at the upload page. I have FF4 and W7.

Uploading from what site?