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.
- Example
- Requires you to be logged in
- Won't work properly until danbooru adds support for piapro uploads
- 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.
Updated by Hillside Moose