Script to copy a book to a manual entry

CharlasHacking LibraryThing

Únete a LibraryThing para publicar.

Script to copy a book to a manual entry

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

(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:34 am

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:12 am

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:17 am

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:28 am

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:35 pm

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:02 am

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:24 pm

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:43 pm

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:40 am

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:18 am

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:12 am

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:25 am

Ain't that always how it is? ;)

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

14rosalita
Feb 19, 2012, 9:05 pm

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:43 am

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:57 am

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

17brightcopy
Feb 20, 2012, 10:42 am

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:54 am

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

19brightcopy
Mar 9, 2012, 10:25 pm

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:02 am

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

21guido47
Ene 17, 2013, 7:39 pm

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:49 pm

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:08 pm

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:50 pm

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:24 pm

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:06 pm

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:35 am

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:46 am

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:20 am

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:38 am

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:22 pm

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:41 pm

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:47 pm

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:20 pm

Thanks all,

Works like a bought one ;-)

35brightcopy
Ene 18, 2013, 6:35 pm

#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:09 pm

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:18 pm

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:22 pm

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:25 pm

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:54 pm

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

41Pebblesgmc
Ene 19, 2013, 8:41 pm

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:52 pm

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:22 pm

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:51 pm

>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:22 am

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:59 am

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:58 pm

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:33 pm

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:10 am

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:16 am

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:26 am

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

52rosalita
Jun 20, 2013, 2:44 pm

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

53brightcopy
Jun 20, 2013, 2:52 pm

That would explain all the sneezing.

54divinenanny
mayo 26, 2014, 8:26 am

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:59 pm

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:00 am

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:42 am

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:39 pm

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:29 pm

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:11 am

>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:09 am

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:15 pm

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:33 pm

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:55 am

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

65Shimmin
Ene 24, 2015, 2:27 pm

#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:23 am

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

67jjmcgaffey
Ene 25, 2015, 1:31 am

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:22 am

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:01 pm

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

Works now!

70Shimmin
Ene 25, 2015, 5:48 pm

#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:26 am

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:02 pm

haven't seen him around for a while

73jjmcgaffey
Ene 27, 2015, 2:11 am

Yeah, I PMed him. We'll see.

74jjmcgaffey
Feb 2, 2015, 3:12 pm

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:13 am

So... is this new version available now?

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

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:38 am

Unfortunately still nothing yet!

78jjmcgaffey
Jun 25, 2016, 1:39 am

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:51 am

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:17 pm

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:52 pm

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:27 pm

>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:30 pm

>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, 2021, 7:05 pm

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, 2021, 2:53 am

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.

86cns1000
Sep 25, 2021, 1:03 pm

I see that this has been a long-running thread. Apologies; this is something I have just discovered. I was looking for a way to quickly copy books to minimize manual effort in entering a whole collection of periodical issues, and it looked like this would be very helpful. ATM I am using Firefox / Greasemonkey and have installed the plugin. I see the two option buttons on the work page, but when I select the work from my books and use the Copy button, apparently nothing gets copied. It looks the same as the Manual Entry page. Am I missing something here ? Would appreciate any assistance.

87Maddz
Sep 25, 2021, 1:10 pm

>86 cns1000: No, that's right. When you select the 'Copy to my Library' button it brings up a pre-filled manual entry page.

The Title, Author, Author Role, Other Authors and publication details are copied from the source record.

Collections: Your Library is always selected, plus if you have a collection selected on the Add books page, that will also be selected.

Tags will need to be entered if you use them, as will Media Type and any other information further down the page.

Provided you don't alter the author and title, the record will be automatically combined with the existing (source) record. Once you've added the book, you can then change the cover and edit the author/title.

88cns1000
Sep 25, 2021, 3:59 pm

Thanks for the reply. By the way, just to confirm, it is on the Book Details page that I am seeing the buttons. The book I am trying to copy is this one:

https://www.librarything.com/work/27106264/details/206331188

When I click Copy to My Library, I do get the Manual Add screen, but nothing has been copied, other than that the "Your Library" checkbox is marked. Everything else is blank. Am I doing something wrong ? Appreciate your help, thanks

89Maddz
Editado: Sep 25, 2021, 4:39 pm

>88 cns1000: Odd, I get this when I click copy to my library:

screenshot

So I don't understand why it doesn't seem to be working for you. Do you have an ad blocker installed?

90SandraArdnas
Sep 25, 2021, 5:21 pm

>89 Maddz: You seem to be using Chrome, as opposed to FF.

91Maddz
Sep 25, 2021, 5:29 pm

>90 SandraArdnas: Yes, I am...

92anglemark
Sep 25, 2021, 5:46 pm

It no longer works in Firefox for me either.

93cns1000
Sep 25, 2021, 7:05 pm

Not running any ad blocker or popup blocker. Firefox is the latest version, 92.0.1. Restarted and cleared cache; made no difference. Most of the settings are default; security level is standard.

Block pop-up windows
was on
Warn you when websites try to install add-ons
was also on

I set both of them to off; that made no difference either. Will try all this with Chrome and see what happens.

Any other suggestions would be appreciated
Thanks

94cns1000
Editado: Sep 25, 2021, 7:48 pm

Ok, apparently there is no Chrome option since this is just a Greasemonkey script. So I guess I can forget about the Copy function ?

Edited later: actually, reading more carefully, there is a way to install the script in Chrome with Tampermonkey. And it works; tested it with the same entry.

Would be really nice if it copied a few more fields, but for now I won't complain.

Thanks

95jjmcgaffey
Sep 30, 2021, 1:54 am

Yeah. Not complete, but _very_ helpful. It stopped working in Firefox/Greasemonkey some time ago, and no one's gone in and fiddled with it to see if the problem can be fixed. But if it works in Chrome, that's a decent workaround for entering a bunch of stuff.

96Keeline
Nov 3, 2021, 1:37 pm

If you find that there are specific fields that are not being copied by the current script, you can try your hand at following the pattern used for the current fields and adding the ones you want. There are a couple places where the data is collected from the detail page and written to the blank entry form.

I use Chrome / TamperMonkey on a Mac for this.

I think there were choices made to exclude certain fields (like tags) because one person's tags may not be another's.

James

97Maddz
Nov 3, 2021, 3:49 pm

>96 Keeline: It's sometimes useful to copy tags when you're cloning one of your own entries (looks at the comic books I entered over the summer) but I agree it's not useful when you're cloning someone else's record.

Is there a way to toggle fields?

98Keeline
Nov 3, 2021, 4:00 pm

Probably not at the front-end side of things. However, if you looked at the script, you could comment out any defined value that you do not want to copy. For example, I see:

var ltcbLanguage2 = { key:'ltcbLanguage2' , id:'bookedit_lang2' , field:'field_lang2' };
var ltcbLanguageO = { key:'ltcbLanguageO' , id:'bookedit_lang_original' , field:'field_lang_original' };
//var ltcbVolumes = { key:'ltcbVolumes' , id:'bookedit_numVolumes' , field:'numVolumes' , path:'//tdtext()="Number of Volumes"/../td@class="bookeditfield"'};
//var ltcbPages = { key:'ltcbPages' , id:'bookedit_pagecount' , field:'pagecount' , path:'//tdtext()="Pages"/../td@class="bookeditfield"'};


The double slashes at the beginning of a line in the script are comments.

James

99bnielsen
Nov 3, 2021, 4:03 pm

I wonder if one could use Selenium to automate a kind of restore from an export file or maybe more useful: something like Power Edit just under program control. Would that make sense? Has anyone tried something like that?

100Keeline
Nov 3, 2021, 4:07 pm

One thing I notice about the displayed content for Tags: is that the content includes a lot of links so you can show the other books in your catalog with that tag:

<tr class="visible"><td class="left">Tags</td><td class="bookeditfield" id="bookedit_tags"><a href="/tag/ULTB" target="_top">ULTB</a>, <a href="/tag/science" target="_top">science</a> </td></tr>

This could make it hard to work with since what you'd really want to paste into the input field on the blank form is:

ULTB, science

So it might take some extra Javascript to strip out the unwanted tags before pasting into the form in the function defined lower in the script.

Some programming is trial and error before occasional success. If you mess up the script badly, you can remove it and reinstall it.

James

101Maddz
Nov 3, 2021, 6:02 pm

>98 Keeline: Unfortunately, I'd be thinking along the lines of a pop-up that allowed you to either select the field as is or to replace the content with your desired content. The selection should persist record to record; effectively, you're pre-selecting the content, a bit like how collections and tags work on the Add Books page.

Either way, it's probably best not to fiddle too much until LT2 is fully rolled out...

102Keeline
Nov 3, 2021, 6:08 pm

We’ve been waiting a very long time for promised changes. Maybe they will be available soon, “in two weeks,” or not at all.

James

103bnielsen
Nov 4, 2021, 2:13 am

>101 Maddz: "it's probably best not to fiddle too much until LT2 is fully rolled out..."

Yes, stationary targets are better than moving targets.

104cns1000
Editado: Nov 6, 2021, 7:24 pm

Este mensaje fue borrado por su autor.

105cns1000
Ene 13, 2022, 1:03 pm

Caution regarding Tampermonkey: I had it installed in Chrome though had not used it much lately. I am using latest version of Chrome on Windows 7. Yesterday I suddenly began to get errors: STATUS_ACCESS_VIOLATION. Was not able to access ANY web sites in Chrome, though the internet connection was fine and Firefox worked on same computer without problem. Referencing the error, I find posts referencing issues with extensions and specifically Tampermonkey (which was one of only two or three extensions I have installed). I could not access the settings page either in order to disable the extensions. Oddly enough, the ONLY site I could access in Chrome at that point was LT.

Only way out of it was to uninstall Chrome, reboot, and reinstall it from scratch. Seems to be working ok now; the first thing I did was disable Tampermonkey.

106Maddz
Ene 13, 2022, 4:10 pm

What scripts did you have installed? I've only got the LT script and it's not given me any trouble and I've used it today. It may be another script?

107cns1000
Editado: Ene 14, 2022, 10:34 am

I only have three other extensions: DOCs/PDF/Powerpoint viewer (by Google), Mailto:, and Google Docs offline. I don't think any of those would present problems. Anyway, at this point I don't know. There was a freeze (not typical) which required me to do a hard reset just before this happened, so maybe something else had gotten corrupted. All seems ok now but I have not reenabled Tampermonkey. No scripts at all other than the LT Copy script in Tampermonkey

108Keeline
Ene 14, 2022, 11:52 am

>107 cns1000: Often when someone has TamperMonkey installed, they may install more than one script in it. That was the reason for the inquiry.

I have MacOS X 10.15.7 (Catalina) with Chrome (96.0.4664.110) and TamperMonkey (4.13) and LT Copy Book (2). I just confirmed that it works. I also have some other TamperMonkey scripts installed.

Sometimes permission errors like you mention can be related to other things, including the operating system, its version, and configuration settings.

James

109Keeline
Ene 14, 2022, 12:00 pm

With a little Google research I see that the STATUS_ACCESS_VIOLATION is a transitory memory-related error where something tried to access a part of memory to which it was not entitled. This can occur when a program has been running for a long time and exceeds its allocated block of memory. Thus, it is probably not specific to TamperMonkey or the LT Copy Book script. The freeze and hard reset solution is consistent with an out-of-memory problem that sometimes occurs on computers.

https://appuals.com/status_access_violation-error/

The STATUS_ACCESS_VIOLATION is a random error encountered by the users while browsing the web on Google Chrome. Even some users also reported the error on the most stable version of the Microsoft Edge browser....


After a restart, you may not run into it again for a long time.

James

110cns1000
Ene 14, 2022, 7:31 pm

>109 Keeline:
Thank for doing the research on it. I'm hoping I won't see it again for a long time, because it was very messy. And yes, the computer had been on for a long time (like weeks probably).

111pnppl
Editado: Feb 27, 2022, 7:45 am

Is this still working for anyone? Edit: I got it working by commenting out a line in the writeData function:
$x1('//td@id="bookedit_tags"//inputvalue=' + collection + '').checked = true;

I... honestly have no idea why. I don't remember commenting it out while I was trying to fix it. It wasn't an avenue I was pursuing. A coding fugue? I'm not even sure what it does, but it seems to work just fine without it.

Anyway, hope this helps someone. This is on Debian Bookworm with Violentmonkey 2.13.0. I can't get it to work with Greasemonkey, but it does work in both Chromium 98.0.4758.102 and Firefox 91.5.0esr.

Went ahead and put it up on Greasyfork: https://greasyfork.org/en/scripts/440672-lt-copy-book-fixed-2022-02-27-libraryth...

112whbclibrary
Ene 6, 2023, 12:43 pm

I have just tried both the original LT Copy Book script and the 'Fixed' Version on Chrome using the latest Tampermonkey and scripts from greasyfork. Tampermonkey says it's enabled, but I am not seeing any buttons added to LT pages. I went to the library item cited by cns1000 in post #88, clicked on the Add To Library button and it brought me to the pre-filled in manually add page. I had tried restarting Chrome but to now effect. Any ideas?

113bnielsen
Ene 6, 2023, 1:17 pm

I don't get it. Isn't "it brought me to the pre-filled in manually add page" precisely what the script is supposed to do? I.e. copy the details from someone elses catalogued book into the manually add page, so you can either just click Save or fix any differences before saving?

114whbclibrary
Ene 6, 2023, 1:19 pm

Interesting: I did a search on all of LibraryThing for a book (not my library) and found it in other libraries. The Add To Your Books button showed up on the right but when I clicked that button, it only added the title to the Add books search box and no titles were found. Perhaps, these buttons were always there, I can't remember, but they did not function as the script says.

115whbclibrary
Editado: Ene 6, 2023, 1:28 pm

To bnielson: I want to make duplicate copies of books from my own library that are in a series and edit them a bit so I don't have to re-enter everything. The location of the buttons in cns1000's book were right on the details page, whereas the book I searched for was off to the side. It seems the script was working in his library, but not mine. I looked at cns1000's book page and the add to library button was also on the right-hand side. When I clicked the right-hand side button, it added the tile to Add Books search box as with the other one, so I think that is a standard button in LibraryThing.

116bnielsen
Ene 6, 2023, 1:59 pm

>115 whbclibrary: Ah, that makes sense. Maybe the script acts differently in your own library. I haven't used it so I'm certainly no expert :-)

117Keeline
Ene 6, 2023, 9:46 pm

I just checked the script from a book in my collection.

First you want to start with the detail page for a work (not the work page).

I notice that holding a command key (Mac) and clicking on the button does open the form in a new tab but it is blank.

However, if I just click on the green "Copy to your library" button, the detail page is replaced with a form that has most fields filled in (as designed).

I am using the version 2.1 (2022-02-27) of the script with TamperMonkey on Chrome.

James

118sbisson
Editado: Ago 15, 2023, 5:50 pm

for anyone else who comes along and is struggling with this script the way I have been, it only works on the book detail page so when you find the book you want to add, you have to click on the number of other members who have it, pick on and find it in their library and open it so you can see *their* book details page. currently working for me in Edge (Microsoft's Chromium browser) and about to save me a LOT of time entering SFF magazines the iOS app couldn't find!

119brightcopy
Editado: Ago 21, 2023, 5:30 pm

When sbisson messaged me to ask about it working on the Works page, I spent a bit of time to make it do so. This can come in handy if you want a super-generic entry. I also fixed a couple of bugs that had either been there all along or cropped up with site updates. Like it not actually picking the correct collection to put it in when you clicked on the My Library vs My Wishlist buttons. I think this was related to pnppl's issue, as that bit of code was related to the collections.

I uploaded it here: https://pastebin.com/raw/ez58XFXr

It can replace the copies at GreasyFork now. And yes, all my scripts for LT and 100% public domain, and can be marked as such. Share and enjoy.

120pnppl
Ago 21, 2023, 11:13 pm

>119 brightcopy:
Awesome! Thanks for such a useful script! Updated it on Greasyfork.

121Maddz
Ago 22, 2023, 12:05 am

>119 brightcopy: Aw, just finished entering my remaining White Dwarfs last week…. Still, I have digital versions yet to add…