Script to copy a book to a manual entry

Se habla deHacking LibraryThing

Únase a LibraryThing para publicar.

Script to copy a book to a manual entry

1brightcopy
Editado: Ene 18, 2013, 6:38pm

(Discussion continued from here.)

LT Copy Book - LibraryThing

This script adds buttons for "Add to library" and "Add to wishlist" onto every Book Detail screen. When clicked, these buttons copy data from the book currently on screen and take you to the manual entry page. Data from the previous screen is pasted into the fields on the manual entry screen.



2brightcopy
Mayo 9, 2011, 10:34am

One thing I also wanted it to be able to do is let you choose a collection from a dropdown and click a button to add it to that (rather than just Your library and Wishlist). But I had no way of getting all the names of the collections from this page. My only solution was that I could have an edit box and let you type the collection name there and it would remember it for next time.

3anglemark
Mayo 9, 2011, 11:12am

And it works on a localised site. Shall I burn offerings to you, or is it OK with a more general, low-key worship?

4brightcopy
Mayo 9, 2011, 11:17am

3> Thanks. :) I've tried from the beginning to make all my scripts not care if you're on www.librarything.com or not. The only ones where I had to compromise was if there was simply no way grab the element for the data I need and had to depend on the language-specific text. That's pretty rare and I think I've been good to note when it happens.

This is also one of the reasons this script doesn't grab physical stats. The html where those are listed is completely devoid of any useful ids and such that I can use to figure out what the data is. So even if I went to all the trouble of coding something to try to get it, it'd be limited to English-only. Just not worth it at this point. Besides, I think the people who really care about physical stats may be doing their own measuring just to be sure. ;)

5brightcopy
Mayo 9, 2011, 11:28am

3> Oh yeah, I should mention there is a spot that does prefer English. Author names are listed on the Book Details page as Firstname Lastname. That means I have to try to do some voodoo to flip them back around. I basically take the bit after the last space and assume that must be last name. But I have a bit in there that cheats and tries to fix suffixes.

So: Martin Luther King Jr.
Becomes: King, Martin Luther, Jr.

The strings it looks for are JR|SR|III|IV|V|VI|VII|VIII|IX. This is definitely very English-centric. I'll look at adding a menu option where you can enter your own list of suffixes for it to use.

6jjmcgaffey
Mayo 9, 2011, 9:35pm

Thank you! This is wonderful. I don't actually add books from others' listings very often...but every time I do it's an utter frustration. Saved! (one more download...)

7Noisy
Mayo 10, 2011, 4:02am

If you could do a version that just did title and author, that would be wonderful. A suppose the alternative is to find a page which only has those elements on it.

Of course it's FF only, isn't it? I just access my wishlist account from MSIE to stop having to switch logins

8brightcopy
Editado: Mayo 10, 2011, 3:24pm

It should work in chrome, especially if you install the tampermonkey addon.

When you say just title and author, do you still mean from book details or from the work, where there are already the add to buttons?

ETA: If it doesn't work for you in chrome, give me a shout and I'll check it out.

9Aerrin99
Mayo 10, 2011, 2:43pm

Wow. I don't do much of this sort of thing, but I can definitely appreciate how awesome this can be for folks who do.

10jjmcgaffey
Ago 10, 2011, 1:40am

I just used this a couple dozen times to enter my new volumes of a...well, a sort of magazine (filk songbook, bi-monthly). It was fantastic - _so_ much easier than entering or even copy-pasting - I just started with one issue I already had and only had to modify the issue number and the publication date.

Well. Actually I had to modify/add rather more than that, because I needed to add them to a second collection (besides Your Library), and needed to add the tags. The script doesn't notice either of those, and I'm not sufficiently proficient to write them in. I did use the try/catch to open up the collection list so I didn't have to click on Show All each time (commented out the if and the checked(false), which left Your Library checked and the list open). But I couldn't figure out how to add it to another collection, nor how to copy the tags. Any chance of that dialog box, or even a place to put collection numbers? I can find the numbers on the Stats/Memes>Collections page (click on an overlap and see what the one you don't know is), but I don't know where to put it to make it add. I tried a second variable just below the $x1 (same data except not the variable collection), but that blanked everything - nothing copied.

I'm perfectly willing to go messing around in the script to make it do different tricks for different uses (I want the tags from my own books, probably don't want someone else's), I just don't know what to mess with. A GUI would be nice (checkboxes for different elements?)...but a lot of trouble, right? and this is so nice as is I don't want to seem greedy.

11brightcopy
Ago 10, 2011, 2:18am

Glad it's been useful for you. I probably won't have any time to update it anytime soon because, well, busy. Having it let you pick collections was one of those features I wanted but just never got a chance to add.

But I do think you should be able to hack around it and force the collection by changing line 239 from:

var collection = GM_getValue(ltcbCollection.key);

to

var collection = 5;

Or whatever your collection id is.

A better solution for you might be to hijack the "add to wishlist" button. Change line 114:

function addToWishlistClick() {
addToClick(4)
}

to

function addToWishlistClick() {
addToClick(/* your collection id */)
}

Or are you wanting to add it to more than one collection at the same time? My sleep deprived brain has just thought of that. This is doable, too. Just let me know.

12jjmcgaffey
Editado: Ago 10, 2011, 3:12am

Yes, it's the two collections at once that gets complicated. Though...I just thought...if I replace the $x1 variable collection (line 243) with my other collection ID, then use the try/catch to check the first child, that would work (I want Your Library and a different one (Working On)).

And congrats - I'd missed your news! He's a cutie.

ETA - OK, so it works fine if I tell $x1 to check both of them (using the variable collection and the ID, in a second, duplicated line). That's even easier, and will work with Wishlist as well.

And I figured out tags, too - copied the lines with ltcbTitle and changed them to ltcbTags. Works! I'll have to comment out three lines if I don't want tags, but that's fine.

Heh. So all I had to do was ask for help, and I'd figure it out myself... Thanks!

13brightcopy
Ago 10, 2011, 6:25am

Ain't that always how it is? ;)

And thanks. He needs to be a cutie at times like these...

14rosalita
Feb 19, 2012, 9:05pm

I love the idea of this script, but I don't seem to be able to make it work properly. I'm sure I'm just doing something stupid.

First, I installed the script using TamperMonkey in Chrome.

Here's what I did: I was on my recommendations page and saw Jane Eyre listed. I've already read it, but apparently had not added it to my catalog. I clicked on the title and it took me to the work page, but there was no link to the Book Details page. So I clicked on one of the member names under Recently Added By, navigated to their catalog, searched for Jane Eyre, and clicked on it. That took me back to the Jane Eyre page, but now there was a link for Book Details. I clicked it, and sure enough I had a second set of "Add to your Library" and "Add to Wishlist" buttons, located just where you show them in your screenshot in message 1. I clicked on "Add to Library", and it did indeed open up the manual entry form, but Title, Author and the other fields all said Undefined instead of being filled in with the Jane Eyre data.

Obviously I must be doing something wrong to even get to that page, because the way I did it is even more unwieldy than the built-in way, but then what did I do wrong to not get the pre-filled fields? Sorry for being such a dunderhead.

15brightcopy
Feb 20, 2012, 12:43am

After exhaustive testing (well, *I'M* exhausted!), I tracked this down to a bug in TamperMonkey and have posted to their forum:

http://forum.tampermonkey.net/viewtopic.php?f=17&t=237

If they get it fixed, the script should work again. I'll keep an eye on it and post here if I hear anything.

Thanks for letting me know!

16rosalita
Feb 20, 2012, 8:57am

Thanks, brightcopy! Sorry to put you through all that.

17brightcopy
Feb 20, 2012, 10:42am

Don't worry about it. :)

That was a bad bug that probably would have affected several of my scripts (not to mention plenty of other peoples). And the author of TM had been trying to track it down a for a while so I was in a good position to know exactly how to reproduce the problem. Everybody wins.

The TamperMonkey author has fixed the bug in the beta version of TM. I've posted to ask when it will hit the main TM extension because switching to the Beta means you have to reinstall all your scripts (a pain). Hopefully it will be soon.

I'll keep you posted.

18rosalita
Feb 20, 2012, 10:54am

Wow, that does sound like a win-win-win situation! I'll look forward to your "all-clear" message.

19brightcopy
Mar 9, 2012, 10:25pm

It looks like the most current version of Tampermonkey has the fixes. So you might want to update now. Have fun!

20rosalita
Mar 10, 2012, 12:02am

#19 by brightcopy> Works like a charm! Thanks so much for this.

21guido47
Ene 17, 2013, 7:39pm

Just followed the link in #1. Downloaded.
All I got was "another" toolbar 'Utility chest' which also tried to change my default home page.

Umm. What did I do wrong?

22brightcopy
Ene 17, 2013, 7:49pm

That sounds odd. When you say you downloaded it, do you mean you clicked on the Install button on the "LT Copy Book" page?

What browser do you have?

Nothing like that should have been installed. It sounds like some kind of adware.

23rsterling
Ene 17, 2013, 8:08pm

21 - What you clicked on was an ad with a "download" button image in it. What you needed to click on was the "install" button at the top right of the page.

Those "download" ads -- ads with fake download buttons -- are ruses used by spammers, adware, etc. You should uninstall the toolbar then run a scan for malware or adware. Then, it probably wouldn't be a bad idea to install some kind of ad-blocker in your browser.

24guido47
Ene 17, 2013, 9:50pm

Thanks rsterling, done. And it did take over my home page. I'm used to that and do watch for that.

Does that script work on IE8. If not I guess I could have a separate shortcut which opens LT in "Firefox".

I usually don't worry too much about which browser I use, and refuse to engage in any "wars", which even in my day, "...CDC is better than IBM..." were silly (of course I am talking about mainframes :-) .

25guido47
Editado: Ene 17, 2013, 10:24pm

I wasn't sure, but should I download Grease monkey? Except the download button was grayed out for me. In IE. Should I be in FF?

G.

PS. I have forgotten how to make a desktop shortcut in FF. Any prod to my 'grey matter' appreciated :-(

26brightcopy
Ene 17, 2013, 11:06pm

Sorry to say, but IE had terrible GM support. You'll have to use FF or Chrome. If you use Chrome, install the TamperMonkey addon before any scripts.

27guido47
Editado: Ene 18, 2013, 2:35am

OK, feeling a bit fragile (birthday soon past, whatever...)

So to use your script I should:

1) be logged into LT under FF.
2) I should down load the script.
3) I should download Greasemonkey (still grayed out for me) but I'll get around that (I hope)
4) what next?

Guido.

ETA. What is the difference between 'GreaseMonkey' & 'TamperMonkey' and which should I use?

28brightcopy
Ene 18, 2013, 2:46am

If you are using Firefox, first install the Greasmonkey addon from: https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/
If you are using Chrome, first install the Tampermonkey addon from: https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldm...

Once you do that, then go to this page: http://userscripts.org/scripts/show/102522
Click on the green "Install" button at the top-right.

To use it, follow the instructions and screenshots here: http://userscripts.org/scripts/show/102522

Give me a shout if it's still confusing.

Happy Birthday!

29guido47
Ene 18, 2013, 4:20am

Thanks brightcopy, old age is still just that.

Well, I'm in FF, installed 'greasemonkey'.
installed the script. then went to a NON MINE book on LT.
Went to add book to "my library", then went to Manual entry, expecting to see the details in the
book details. Nope. Next baby steps please :-)

30brightcopy
Ene 18, 2013, 10:38am

The step you may have missed it to make sure you go to that non-mine book and click on Book Details. Then click the Add to your library button on the right.

It used to be less confusing because LT didn't put its own buttons on the Book Details page when I created the script. I should probably re-write to take over theirs.

31jjmcgaffey
Ene 18, 2013, 3:22pm

No, please - yours are in a different place, if you took over theirs I wouldn't know which ones to click (I'd never be sure I was in the right place to use your script).

guido - you have to be in book details, which means you have to find the book through a person (anyone who owns it) rather than getting to the work page as usual. You'll see _two_ sets of green and pink pluses on the right page - click either of the lower, right-hand ones to activate the script.

Here's an image - I went to your library, found a book we didn't share, went to the Book Details page and (after some difficulty, see below) saw the proper script buttons.



The proper buttons are circled in red - and on the left, you can see I'm in the book details page (also look at the URL). If you just go to the work, there's no Book Details available - you have to be in a particular library.

brightcopy, just another weirdity (nothing to do with your script, really, just FYI). I went to the page and there were no script buttons; in surprise, I looked at the URL and saw https - and a globe! So if people haven't done the workaround to unhide the http and https, the globe and lock can lie.

32brightcopy
Ene 18, 2013, 3:41pm

Yeah, maybe I should just change my buttons to say something different.

Bleh about the https. I should probably just update all my scripts to load on https as well as http.

33r.orrison
Ene 18, 2013, 3:47pm

Since you call it the Copy Book script, how about changing the buttons to "Copy to your library" and "Copy to your wishlist"? (or even "Copy Book to your ..")

34guido47
Ene 18, 2013, 4:20pm

Thanks all,

Works like a bought one ;-)

35brightcopy
Ene 18, 2013, 6:35pm

#33 by r.orrison> Because that would require new screenshots, silly!

Okay, okay, I've taken your suggestion. I've also made it work with both http/https. The new version is uploaded.

guido: you don't have to update, but if you want to just go to the userscripts link above and click the green Install button.

36rosalita
Ene 18, 2013, 7:09pm

So, when I checked for userscript updates in TamperMonkey, it said there were no updates. Should I be doing it differently?

37brightcopy
Ene 18, 2013, 7:18pm

Hmm, not sure as I don't use TM regularly. When you use the script, do you see "Add to your library" (on the right, in Book Details) or do you see "Copy to your library"? If the latter, you are up to date.

If not, try going to the script page and clicking the green Install button and then do the above test. Let me know what happens and then we'll both know how well the TM update works. :D

38rosalita
Ene 18, 2013, 7:22pm

I went to your library and selected Cod to add to my wishlist. When I went to the Book Details screen, it did indeed say 'Copy to ..." so I guess it updated automagically!

Thanks again for a super-useful script. I hope the book's good, too. :-)

39brightcopy
Editado: Ene 18, 2013, 7:25pm

Huzzah!

Edit: And yes, I found it quite enjoyable. As was Salt, which overlaps in some places but is much larger in scope.

40rosalita
Ene 18, 2013, 7:54pm

Yes, I already have 'Salt' in my library, waiting to be read.

41Pebblesgmc
Ene 19, 2013, 8:41pm

You are all so smart,
I've no idea how to any of what you are doing really.
But I sure admire that you can do what your doing.
Keep up the great work what you doing will reach my
computer illitate self some day in a form for
Computer Dummies:)

42Osbaldistone
Feb 26, 2013, 2:52pm

Brightcopy,

On another thread, you asked what fields I would want from your script that it doesn't provide.

The simple answer is: all of them, except the personal fields such as 'Comments', just as LT used to allow. I want the cover, the dimensions, page count, etc. You see, my primary need is for books, such as Easton Press and Folio Society, which have no ISBN's. Collectors of these editions maintain pretty accurate catalogues, often with very nice images. But many cannot be found using the 'Add-books' search function. When I can go to an FS or EP collector's catalogue and see all the data I need, it's pretty annoying to have to manually enter every field and then go searching for the cover among what is sometimes over 100 covers. But, I'd be okay without the cover if the rest were easily captured.

The real problem, though, is that my main browser is IE. I have Chrome as an alternative, and I got it setup with add-ons to allow your script to run, but the add-on was unstable - it fought with Norton anti-virus/firewall. So, for now, I can't use your script. I'll probably just get off my rear and get Firefox installed. But for now, I can't run your script to see what it does and does not capture.

Consider my comments simply as input for any future work you may put into your script.

Thanks,
Os.

43brightcopy
Feb 26, 2013, 3:22pm

Thanks for posting. Was the addon for Chrome TamperMonkey? If not, that's what you should be using. I've never heard of it being unstable but browsers are odd creatures (on one machine, the Delicious bookmarks toolbar just suddenly and stubbornly started refusing to show).

Just to recap:

What it captures
Title
Author
Other authors
Publication Date
Publication
ISBN
LCCN
Dewey
Primary/Secondary/Original Language

What it doesn't capture that you'd probably want
Number of volumes
Number of copies
Pagination
Dimensions
Weight
Lexile measure
Summary

What it doesn't capture that's probably not what you want
Tags
Comments
From where
BCID

What I probably can't capture
Physical Summary (doesn't appear on add books page)
Cover (see below)

I'll look into the other data when I get a chance (working on a big LT script at the moment - stay tuned!) I think I remember looking into the dimensions but it was just too tricky for me to want to spend time on, since that data has a more complex structure and required digging deeper into the guts of the LT javascript code. And then there's some data that's simply lost when it shows it on the Book Details page. For example, if you have Pagination set to 10 pages of the form i,ii,iii and 20 pages of the form 1,2,3, that shows on the Book Details page as "10; 20". It just totally leaves off what kind of pages. So I'd never be able to do anything there other than just always defaulting to 1,2,3 type pages.

The covers are, alas, not really possible due to the way the LT code works. I can't add a book and specify the cover at the same time. I could try to hack up some kind of multi-step thing, but it'd probably be far too error-prone. In fact, now that I think of it, it's almost impossible due to the way LT names the cover image on the book page versus when you have to pick the cover off the covers page.

44Osbaldistone
Feb 26, 2013, 9:51pm

>43 brightcopy:
Yeah, that about summarizes what I'd add and what I wouldn't expect and/or want.

Re: trouble with TamperMonkey on Chrome, I had it working just fine. But, I've had problems with Norton related to Chrome and IE and have had to disable its firewall/virus protection on IE just to get it to work. Chrome add-ons are disabled upon loading, and I get an error message identifying Norton as the problem. It's Norton, not the browsers, and seems to be related to an update from about 6 weeks ago. In the process, I lost access to my cloud backup files and lost the data in their 'password vault' app, meaning, I've lost the login info for dozens of websites, right when I'm in the middle of an extended job search, logging on to many corporate and job hunt websites. I'm sick of spending hours with customer support, and will probably look into McAfee.

Anyway, that means I won't be able to use your script for awhile anyway. But, being out of work, I'm also not buying books right now, so no loss. I appreciate your volunteer efforts and look forward to whatever updates you decide on.

Os.

45JerryMmm
Feb 27, 2013, 5:22am

I would prefer people took the time to check for their own covers, as as time goes by, better covers get uploaded, and far too few are updated after initial selection.
There is a quality continuum of course, from illegible to decent to good to perfect, but blindly copying the cover, even decent or good ones, misses the chance of finding the perfect version for your edition.




I haven't installed this script on Opera yet, is your omission of Opera an indication as to whether it will work or not?
Your Search directly in member's catalogue script works fine btw.

46brightcopy
Feb 27, 2013, 10:59am

Well, I can't copy the cover so it's really a moot point. :D

As far as Opera goes, god only knows. I don't go out of my way to support it, but since I try to make things not Firefox-specific there's a good chance it will. But often there are quirks, like a thing I'm running into where I'm using a perfectly good bit of code that causes weirdness in Chrome. So YMMV.

You also apparently need to install a script for a few bit of GM support:
http://www.howtocreate.co.uk/operaStuff/userjs/aagmfunctions.js

I believe this would be necessary for this script as it uses GM_setValue.

47rosalita
Jun 17, 2013, 4:58pm

This may be too extreme an edge case, but just in case anyone else is like me ... I would love if the button for Copy To My Wishlist could be customized to point to a different collection as specified by the user. For me, I have two wishlists: the default LT wishlist is for books I know I want to buy, and the To Borrow collection is for books I want to check out of the library. Most books I add using this script go into the Borrow collection. As it is, it is not at all difficult to just switch the checkbox before saving, but if I could set the default as To Borrow, that would save me, well, hundreds of thousands of nanoseconds every year. :-)

48brightcopy
Jun 17, 2013, 5:33pm

Wouldn't be TOO bad to change. The major challenge is that the Wishlist (and Your library) have fixed collection IDs. In other words, everyone's wishlist is collection ID 4.

If you look in message 11 above, I show how to change your script so you can put any collection ID you want in there. The easiest way to get your collection id is probably to go "Your books" and change the collection to the one you want. Then go down to the bottom of the page to the "permanent link" link. It will look something like:

http: // www.librarything.com / catalog.php?view=brightcopy&collectionname=allcollections&collection=57293&shelf=list&sort=copies&sort=copiesREV

Where it says "collection=57293" is the collection ID. Just use that collection ID in my instructions above. You can also change lines 221/222 where it says "your library"/"your wishlist" to a different text if you want it to show on the button that way.

There could be a nicer way of doing it, but honestly I'm just not going to find the time. I have two or three scripts that are broken right now that I really need to find time to update first. Good luck!

49rosalita
Jun 20, 2013, 11:10am

Ah, that solution in Message 11 appears to be exactly what I need. I don't know I could have missed it (except that it was posted way back in 2011, and I can barely remember what I had for breakfast this morning). Thanks! :-)

50brightcopy
Jun 20, 2013, 11:16am

Who are you and what did you do to my typewriter it has all these blinky lights and I can't figure out where to put the paper in!

:D

51rosalita
Jun 20, 2013, 11:26am

Ha! Take a tip from me: Don't try to use the Liquid Paper correction fluid on the screen!

52rosalita
Jun 20, 2013, 2:44pm

It worked! You are the cat's pajamas, brightcopy.

53brightcopy
Jun 20, 2013, 2:52pm

That would explain all the sneezing.

54divinenanny
Mayo 26, 2014, 8:26am

Hi Brightcopy. I'm working on my own local library database (using MySQL and PHP). I would love to code something that would take my entry in my database and copies the data into the Manual Add form. Can you tell me how (or which part of your code) you pass the values you copied into the Manual Add form?

55nandadevi
Editado: Oct 20, 2014, 11:59pm

Note that the location where GreaseMonkey scripts were stored (and where the links on previous posts point to) has been closed down. These scripts, and links, previously pointed to userscripts.org. If you try to link to that location you MIGHT be taken to a mirror site, but the mirror site has very little of the functionality of the original site, and will not take you directly to the LibraryThing scripts. Manually navigating (there is no search function...) to the scripts could take days (browsing over 5000 pages)

HOWEVER, all the scripts previously stored in userscripts.org (including the librarything ones) are now available at http://www.webextender.net/index.html To get to the LT scripts from the webextender home page simply use 'librarything' as your search criteria.

56jjmcgaffey
Oct 21, 2014, 3:00am

Thank you! I've been finding scripts in various places, but none of them had full functionality - particularly, none of the ones I found had good searching.

Want to post this in the general thread too? I mean the Sound Off thread - http://www.librarything.com/topic/82389 . I see you posted it separately as well, that's good.

57Shimmin
Ene 3, 2015, 7:42am

Hi Brightcopy,

I've just installed and tried using this script. The buttons appear, but the information is not copied across into the manual entry page. Any suggestions?

I'm on Firefox 34 on Windows 8 if that helps.

58jjmcgaffey
Ene 3, 2015, 12:39pm

It hasn't worked for a few versions of FF - at least since 32, probably further back. Or possibly it's an LT change that coincided with a new FF version. And brightcopy hasn't been around much, unfortunately.

I've done some poking around in the script and fixed something before, but haven't tried with the latest null results. You could try it...open up the script and see if you can figure out what's supposed to do what, compare what it's trying to link to with what's actually on the page (View Source), and see if you can make it behave itself.

I'll do the same...if I ever get a free minute! I've been intending to for months.

59Shimmin
Ene 3, 2015, 3:29pm

Thanks JJ (should I call you JJ? something else? it feels weird using full names...), that's good information.

Okay, I might take a look at it as I should have some time this week. That being said, I've never touched Greasemonkey before, so don't get your hopes up! But I can roughly handle Javascript.

For info: do we know if Add Book pages always have the same number of fields in the same order, and in every language? It's possible that this would offer a slightly different way to handle things than the current approach, or a handy backup.

60jjmcgaffey
Ene 4, 2015, 1:11am

>59 Shimmin: JJ's fine, or Jenn, or Jennifer (my name - though you'd have to go to my profile to find that out).

Yeah - I know a little Javascript and a little Java and a little bit of a lot of things, and was able to change the script to do what I wanted (put things in two collections, copy tags, etc). That was my first venture into Greasemonkey, and so far my last - too much else going on.

I don't know for certain about the page, but there isn't any way of rearranging things (the way the profile and the book pages can), so I suspect it is the same. However, that doesn't mean it will stay the same down the line - Tim et al do a lot of reconfiguring of one sort and another, from adding new fields to support new features to cleaning up old odd code. Which may just mean that someone else will have to fiddle it again, if you get it working and LT staff break it with new stuff.

61Shimmin
Editado: Ene 23, 2015, 4:09am

Hi JJ,
success! The problem seems to be the lack of two metablock imperatives, which need adding to the header. Just adding in these two lines before // ==/UserScript== will get things running:

// @ grant GM_getValue
// @ grant GM_setValue

EDIT: so using an at symbol creates a link to a user profile, apparently. Take out the space between at and grant to get the working code...

Incidentally, there's a ton of LT scripts that come up if you search Webextender. The one you want is called LT Copy Book - LibraryThing for Greasemonkey. It's currently at http://www.webextender.net/scripts/show/102522.html - hopefully it'll stay there!

62jjmcgaffey
Ene 23, 2015, 6:15pm

It works, great! It also complained so I added //@ grant metadata (same thing, take out the space). Yes, webextender seems to have taken over from userscript.org - thank goodness.

Now I need to put my changes back in - as I mentioned above, I'd altered it to copy tags as well and to check off more than one collection (and have the collections list open on the Manual Add page). When it stopped working, I went and got a fresh new copy (in case that was the problem) and wiped out my changes...hopefully I saved them somewhere. Or I'll have to figure them out again.

And then I'll try that fix on a few others that have stopped working. Thanks, Shimmin!

63Shimmin
Ene 23, 2015, 6:33pm

Glad it works for you too! I'll grab the metadata one too, good tip.

I have started working on getting physical data, vols and copies in. The last two work in my test version, but I'm having trouble with the way data is transferred into the new record, plus the weird and wacky HTML behind the forms. Not quite what I'm used to. Then I remembered I was supposed to accomplish things today and I was still in my pyjamas at lunchtime playing with code.

64jjmcgaffey
Ene 24, 2015, 2:55am

LOL! So easy to do - "just a couple more minutes, I've almost got this working..."

65Shimmin
Ene 24, 2015, 2:27pm

#64 - tell me about it! Also, apparently I can only code when I should really be doing something else.

So, update - I think it isn't actually possible to get physical data in the way I was hoping, because of the way it's structured. Travelling through HTML nodes only works with a consistent data structure, but LT pages only generate those fields that contain data, so you can't predict whether (say) weight or height actually exist. As such, actually getting the data is just as troublesome as Brightcopy said.

Fundamentally, short of some really complicated stuff analysing the text of fields and comparing to various languages... I don't think we can do this. And who has time to code that?

What would quickly and easily solve the problem would be if those other fields had ids. I have no idea why they don't, and would think it should be easy to add them. So the best way forward might be to just ask Tim to have ids added to the remaining fields so everything is consistent.

66macsbrains
Ene 25, 2015, 12:23am

Unfortunately, I'm not having any luck with the suggested changes (assuming I did them correctly). Alas.

67jjmcgaffey
Ene 25, 2015, 1:31am

There's a // ==UserScript== section that ends with // ==/UserScript== - put the //@ lines in just above the end of that (and make sure to take out the space between @ and grant. And save. That's all I can think of (all the errors I made...).

68jjmcgaffey
Ene 25, 2015, 2:22am

It occurs to me (see the RSI thread) that one of us should upload the corrected script to WebExtender. Do you want to do it? If not, I will. It probably means making an account, and entering the script there...so it won't link directly to brightcopy's version. Not sure if that's possible, though it would be nice.

69macsbrains
Editado: Ene 25, 2015, 12:01pm

>67 jjmcgaffey: Ah! I had a typo! No wonder it couldn't get a "Valeu".

Works now!

70Shimmin
Ene 25, 2015, 5:48pm

#68 Jenn, if you have time that would be great, especially as you already have the extra work you did. If you post a link here, people using LT can probably find it, but as you say, a link on WebExtender may not be possible.

71jjmcgaffey
Ene 26, 2015, 4:26am

I've asked brightcopy if he wants to put the corrected script up; if he's not interested, I'll do it.

72JerryMmm
Ene 26, 2015, 5:02pm

haven't seen him around for a while

73jjmcgaffey
Ene 27, 2015, 2:11am

Yeah, I PMed him. We'll see.

74jjmcgaffey
Feb 2, 2015, 3:12pm

brightcopy says just put it up, it's a public domain script. Missing the point a little, but whatever - I'll put it up shortly.

75Felagund
Feb 28, 2015, 1:13am

So... is this new version available now?

76jjmcgaffey
Editado: Feb 28, 2015, 6:00am

No, sorry, I'm a little swamped - taking a class on Android programming. I'll get it up soon. And link here when I do.

77Godard
Jun 19, 2016, 4:38am

Unfortunately still nothing yet!

78jjmcgaffey
Jun 25, 2016, 1:39am

I lost both my computers simultaneously - hard drive failure on one and I have no idea what was going on with the other one. I'm not sure I still have the script, some of my backups also failed. So no, sorry, I haven't gotten it up (now I have both computers back, but not all the data, and some of it is in weird places). macsbrains, if you have a working copy, could you put it up?

79omargosh
Jun 25, 2016, 9:51am

Ugh, sorry to hear about your computer failures. That's a nightmare. I sprung for remote backup after one hard drive failure, which saved me another time when I had to wipe my drive due to a virus. Anyway ... I put up what I think is a working version of brightcopy's Copy Book script here: https://greasyfork.org/en/scripts/20899-lt-copy-book-librarything

Let me know if it still has problems and I can try my hand at fixing them.

80Keeline
Jun 26, 2016, 2:17pm

omargosh, somehow I missed the availability of this update. My installed copy was identified as v. 0.0 and this is v. 2. It does seem to work for me. I will compare the code to see if I can learn something about this kind of coding. I mainly do PHP and sometimes have JS/JQ for sites. Thank you for reminding me of the availability.

James
_____

81Keeline
Editado: Jun 26, 2016, 2:52pm

Comparing version 0 with version 2, I see only these lines added. I assume they are designed to allow access to some Grease Monkey functions.

Aha: https://tampermonkey.net/documentation.php#_grant

This makes sense since I am using TamperMonkey on Chrome on Mac.

// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @version 2

It is interesting that version 0 stopped working and version 2 works with these changes.

I'd love to see a commented version of this and other GM for LT scripts. In the meantime I'm glad to have the function working again. Thanks again, brightcopy and omargosh for this.

James

82omargosh
Jun 26, 2016, 3:27pm

>81 Keeline:
Yeah, those were the only changes I made. It seems that Grease/Tampermonkey used to allow scripts without the grant stuff explicitly set. And Greasyfork barked at me about not having a version number, so I just added something. But if you find other things that weren't working like before, lemme know and I can try to look into it. (And I try to comment my scripts with what I'm doing ... often for my own benefit when I later can't remember :-) ... but if you'd like more verbiage in the future, I can try to oblige ... though I'm not sure if comments are even allowed in those first lines).

83Opteryx
Oct 24, 2020, 2:30pm

>79 omargosh: If anyone can figure out how to get the Copy Book script working again, that would be sweet... I saw the first include URL needed updating, but that alone doesn't make it work again, and I couldn't figure out the rest of it.

84Keeline
Mayo 10, 7:05pm

The 2.0 version of the script does seem to work. Remember that it is looking for the book details page in this format:

https://www.librarything.com/work/1812/details/113872148

When Chrome : Tampermonkey is on with the script installed, there will be two buttons added to the page labeled "copy to your library" and "copy to your wishlist". The first one is the one I use and it goes to the "addnew.php" script. The key is that most of the fields will be filled in.

I have a notion that if LT2 ever comes about, there will be enough changes that this will break again.

James

85Maddz
Editado: Mayo 11, 2:53am

OK, how does this work? I'm adding comic issues, and doing it manually is a slow process. (Admittedly, I'm towards the end of the process, having 1.25 boxes to go - Cerebus and Promethea, but it will be useful for when I get to obscure small press RPG titles.)

I've enabled Tampermonkey, and got the script, but for the life of me I can't see the extra buttons. Is there a step-by-step guide somewhere?

(Chrome Version 90.0.4430.93 (Official Build) (x86_64), macOS High Sierra version 10.13.6)

ETA: Oh, I see. Instead of the script being able to access the work page, I have to find a member with it to access the book details page which adds several steps to the process. Whether this is less tedious than my current workflow, I don't know - there still seems to be significant typing involved, but at least the entry should auto-combine.

ETA 2: It would be useful if you are duplicating an entry in your library to be able to duplicate the tags used. Pity that the media type isn't included on the book details page as that I have to add manually.

ETA 3: Annoying that the collections automatically include 'Your library' (I have to remember to de-select it). The collection(s) should be taken from the entry (or entries) currently selected on your 'Add books' page.