One-click adding generic editions of works?

DiscussãoHacking LibraryThing

Aderi ao LibraryThing para poder publicar.

One-click adding generic editions of works?

Este tópico está presentemente marcado como "adormecido"—a última mensagem tem mais de 90 dias. Pode acordar o tópico publicando uma resposta.

1brightcopy
Fev 7, 2012, 3:18pm

This is a spinoff of the topic brought up here.

The request is to build a greasemonkey script that allows you to one-click add a book to your Read but unowned collection.

I'm already half-way there with the LT Copy Book script. I could also use rsterling's idea about using the ISBN from the Amazon link (if present). That would allow me to avoid something that makes me a little queasy, which would be to add a bunch of ISBN-less entries. I'd feel a little bad about adding a bunch of these that might make combination/separation a little annoying.

I'm not 100% sure about the "one click" thing, but I could probably do it by faking up the form. I'd have to inspect a bit and see how that form works to be positive, though. Note that the LT Copy Book script is a two-click deal.

2keristars
Fev 7, 2012, 3:35pm

My dream is that it would add title/author (maybe a pop-up dialogue box to edit it?) with everything else blank, or perhaps a special tag that you can set by editing the right line in the GM script, so that it's easy to go back and find all of them.

I understand the queasiness about the lack of ISBN, but for my purposes, I prefer to not have ISBNs unless it's the one specific to the edition I read/own.

Though, ideally, I think what I'm looking for is similar to the Combiners script/bookmarklet - when I'm browsing the web or LT, I can click the bookmarklet, enter title/author, and have a new generic entry to edit later. That might be a bit beyond what you're talking about, and far too open to problematic entries.

3brightcopy
Fev 7, 2012, 4:02pm

#2 by keristars> Ah, interesting take on it, yes. I can see how you'd want to add from other sites as well. The problem there is that you run into a security issue. The browser throws up a wall to prevent javascript from one site from accessing data from another site. If you were on, say, amazon.com and clicked the bookmarklet, the javascript code of the bookmarklet would run as if it were on amazon.com. That'd be fine if it was fetching/submitting data back to amazon.com. But if that site tried to do something with ANOTHER site (LT), the browser would tell it no.

The ways around this require either writing a full-fledged browser addon (not my bag) or having official support from Tim to do something on the librarything.com server (unlikely).

The only other way I can see it is possibly opening a new window/tab when the bookmarklet is clicked. That'd probably work, but would kind of destroy any "one-clickness" about it. It'd open a new window that would be the manual entry page on LT. Then a second script would have to be listening there (much like the LT Copy Book one does) and fill out all the data. Then you'd click the submit button on the manual entry and close the tab.

I'll keep thinking about it a while, though, and see what else comes to mind.

4SylviaC
Fev 7, 2012, 4:24pm

I use your Copy Book script, and really like it. If there was a way to get the title and author from the work page instead of a book detail page, that would cut out the step of getting to the book detail page in the first place. Maybe there could be buttons for "copy generic to read but unowned" and "copy generic to wishlist"

Like keristars, I wouldn't want the ISBN for generic editions, but if you felt too guilty to leave it out, it wouldn't be a big job for me to delete it later.

5jjmcgaffey
Fev 7, 2012, 5:25pm

And personally, I don't mind a two- or three-click add. Copy Book is great - it cuts it down from a long job to "click, adjust bits if necessary, click". The same sort of thing would work here.

6keristars
Fev 7, 2012, 5:43pm

Hmm, I might should try the copy book script, but I really only want a generic title/author to start!

I do understand the problems you listed in #3, brightcopy, which is why I said it's "ideal" - not necessarily feasible without official help.

Would it be possible to have a bookmarklet that does throw open a new tab with the addbooks.php page, filled in for title and author as specified in the dialogue box, then I'd have to manually save it myself?

Because that's honestly the most annoying part of adding these generic books to my catalogue - having to go to the add books page and type it all in. I think the Copy Book script might help a lot, but it won't be as useful from the Recommendations page or from a talk thread.

I wish I had the patience to learn javascript better. I've never got the hang of manipulating code like for this kind of thing, though I always did pretty okay when it was my own (not that I ever got too complex).

7brightcopy
Fev 7, 2012, 5:46pm

Yeah, it's possible to have a bookmarklet that opens the addbooks.php page. But from there another greasemonkey script will have to pick up to fill it in. So totally feasible that way.

I'm going to cogitate on it a while before I actually try to code anything, though. Sometimes I think of better ideas later.

8timspalding
Fev 7, 2012, 11:40pm

I think it's a good idea. We need one-or-two click adding, as well as adding of generic editions. It won't happen tomorrow.

9brightcopy
Editado: Fev 8, 2012, 7:02pm

Thanks for weighing in, Tim. Wish we saw you more around here. :D

So would you be willing to do anything on the LT side, however minimal it might be? What would work well and be easy is for me to send a JSONP request like:

<script type="text/javascript" src="http://www.librarything.com/addbook.js?key=123456789&title=Some+Title&author=Lastname,+Firstname&collections=1,4&callback=SomeFunc"></script>

Where the key would be the one you use for the JSON API (to avoid other people adding books to your account). It would then add a copy of the book with that author and title and put it in those collections. Then the js it spits back will call the callback so we know it's successful. Easy peasy.

Likely?

10justjim
Fev 8, 2012, 5:41pm

Wouldn't it be more efficient if your JSONP request was:

That way the API... OK, I'm making it up now. My point is your code seems to have fallen foul of the HTML parser!

;)

11brightcopy
Fev 8, 2012, 7:03pm

You are clearly delusional, as may post is obviously fine.

Pay no attention to the edited date! I only went back to... Add a comma I forgot.

12justjim
Fev 8, 2012, 8:08pm

It is not possible to be "clear" and "delusional" at the same time! The tiny purple elephant on my shoulder agrees.