GM script: custom author roles

DiscussãoHacking LibraryThing

Aderi ao LibraryThing para poder publicar.

GM script: custom author roles

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

1omargosh
Editado: Jan 26, 2014, 11:33pm

Script here: http://userscripts.org/scripts/show/293281 (as usual, it's the green "Install" button at upper right you want).

Description: If you constantly need to add an "Other..." type of role instead of the ones in the pre-approved list, this script will add those other roles automatically to the dropdown.

The custom roles will show up when adding/editing authors both from your book-editing page and from the public/common work page:



To add to or remove the sample roles that come with the script, select the "Edit custom roles..." option, which will pop up a prompt where you can change what's currently there:



The roles you add will be saved in the browser (localStorage) so that they stick around in the future (the current dropdown might not reflect your immediate changes, but it should after a page reload).

Let me know if you run into any problems.

2omargosh
Jan 26, 2014, 2:01am

Keeline, I didn't put in "Pseudonym" or "pseud." as one of the options that come with the script (I feel differently about that as a "role"), but of course the beauty of the thing is that you can add it to your own list.

3henkl
Jan 26, 2014, 4:18am

Thank you!

4.Monkey.
Jan 26, 2014, 7:29am

Oooooooooooooooooooooooh fabulousssssss!!! I am SO FREAKING TIRED of typing "letterer" "inker" and "colorist" OVER AND OVER AND OVER. I think it's absurd that Tim won't add more or let us add our own or whatever and we're forced with that stupid list that I don't even use half of. This is fantastic!!

5Keeline
Jan 26, 2014, 1:14pm

#2 by omargosh>

Thank you for providing this. I'll test it out.

My personal cataloging preference is to put the name that appears on the book at the topmost author, hence my use of "pseudonym" or "pseud." (common in English-language card catalogs I have seen over the decades).

Even when the name of the ghostwriter is known, it is not the outliner or owner of the book so it is not the same as a personal pseudonym of the "Mark Twain" = Samuel L. Clemens variety. In a perfect world every published use of "Mark Twain" should be interpreted as Clemens' work. There could be exceptions to this. However, even if you know one ghostwriter for "Carolyn Keene," there are dozens of others and the owner was the Stratemeyer Syndicate (and later Simon & Schuster who bought the Syndicate).

This tool will help immeasurably, I am sure. If there are any anomalies I will mention them for possible resolution.

Thank you again.

James

6Keeline
Jan 26, 2014, 1:42pm

I am using Chrome (32.x) with TamperMonkey (3.6.3737.80) on a MacBook (2008 vintage) with Mac OS 10.6.8.

After installing the code I navigated to a book edit page (detail page that you can see) for one that already had a custom role of "Pseud." defined for this work the hard way.

Next I added "Pseud., " to the beginning of the list.



As you noted, the new entry was not added to the list right away. I tried to reload the page, thinking it might show up then. It was very slow to respond (perhaps a temporary LT issue?). When it did reload I was surprised that "Pseud." was not part of the custom list but still showed up on the LT-generated list. Further, there was an extra select list item for customizing the list.



Hitting the customize choice again to be sure the item was in the list, I checked the role select again and found a third customize choice.



Perhaps I should have chosen a fresh book entry without an LT custom role. Using Chrome (and perhaps adding to the beginning of the comma-separated list) could be a factor in the extra menu items.

I will try any further tests you suggest.

James

7.Monkey.
Jan 26, 2014, 3:10pm

If you already have custom roles entered, they'll show as options when you go back to the edit page. I've taken advantage of this previously for graphic novels that have several people with the same roles, so then I at least wouldn't have to keep retyping it for the one book.

8omargosh
Jan 26, 2014, 6:25pm

3 >
You're welcome!

4 >
Thanks for the most enthusiastic response ever. :-) Makes me happy to work on this stuff. I thought I read somewhere that Tim was going keep track of the "Others" that people were actually using (with the possibility that high-frequency uses might graduate to the default list), but not sure if that's true. But from what I've seen doing other activities like author disambiguation, I can certainly tell that all you comic folk have been way busier than people adding Afterwords and Narrators.

6 >
Sorry about the problems and thanks for pointing it out. I'm not sure what's causing the multiplying "Edit custom roles..." but have a hunch and will work on that next. Will do more testing in Chrome, but I'm quite confident that adding "Pseud." to the front of the list wasn't the issue.

6 and 7 >
Yeah, I'm not sure what's the best thing to do with the case where LT "helps out" by tacking on (to the end of its list) custom roles that were already used on that book. Part of my script looks for the roles that are already in the list and prevents duplicates from getting added. One possibility is to try not to bother with this (i.e. if there are duplicates, oh well, there are duplicates). Another possibility is to try to move things around so that they're all in alpha order (and not separate custom roles to their own space). I didn't do this initially because (excuse reason) I didn't want to interfere with previously learned keystrokes, e.g. two "C"s for Contributor, and (real reason) it's more coding that I have to learn how to do. :-)

9.Monkey.
Jan 26, 2014, 6:38pm

Haha, well it'd probably be more intuitive if they were all in one alpha list, but I will take what I can get!

I was reading a thread earlier, I think one you brought up from the depths to mention your having made this, and users mentioned that Tim could possibly do that, but he wasn't in the thread at all. He could have said something elsewhere, but it wasn't in that whole discussion about it, anyway. When I mentioned a while back as an RSI that more should be added, I got jumped on by people who claim the list is too long already and they don't want it cluttered with things they won't use (hrmph! What about the fact that it already is for those of us who don't use what's on it and need what's not!) and that Tim felt similarly (granted that's 2nd-hand info, but people tend to remember his stances on things, lol). It seems by this point that even if he had mentioned he might want to do that, that he's abandoned the thought. :|

10omargosh
Editado: Jan 26, 2014, 11:38pm

Ok, I've updated it (at same place).

James, I think the issue you found shouldn't happen anymore. I've also made it so edits to the role list should no longer require a page reload to show up. (This causes one slight weirdness that in most cases shouldn't be obvious: if you've already assigned a few authors with custom roles, then edit the role list, the previous assignments will be preserved, but they'll now show up in the dropdown at the end of the LT-approved list (similar to how LT sometimes also does this)).

I've also removed the code that removes duplicates. The custom list is now stays constant regardless of whether LT has also added the role to the dropdown.

I also made it work in the "manual entry" page when adding new books (and updated the "add 10 authors" script with this change too).

9 >
Thanks. Perhaps if I get around to implementing your desired behavior (putting them all in alpha order, and not segregated), I could try out two options: "Add custom roles ..." (similar to existing functionality) and a new "Hide specified options ..." which could prevent Afterword and Narrator and whatever else you choose from showing up. But don't hold your breath. :)

Piece of trivia: An aspect of LT's implementation of these dropdowns revealed to me that there are currently about 42000 unique "Other..." roles throughout LT. Though I couldn't tell anything about their frequency.

11.Monkey.
Jan 27, 2014, 11:56am

Hah, interesting.

And don't worry, while it'd be nice if we could explicitly populate our own lists, I'm quite happy with just being able to at least have access to the ones I need, as opposed to the ones "the masses" apparently think are appropriate.

12Keeline
Jan 27, 2014, 3:26pm

#10 by omargosh>

Piece of trivia: An aspect of LT's implementation of these dropdowns revealed to me that there are currently about 42000 unique "Other..." roles throughout LT. Though I couldn't tell anything about their frequency.

I'm not very surprised by this. Every time one of us adds yet another instance of "ghostwriter", etc. there will be a new entry in the "Other..." roles. There's no apparent effort to normalize these (database term) and coalesce the repeats, even for a given user. I don't know for sure that this is the case but if it was tracking them by user, there would be more of a select list feature to pull from past used names.

My quick test of version 3 of this script seems to work. I did not see the multiple "Edit custom roles..." in the select list. However, if I spot anything else, I'll report it here.

Since you mention local storage, I suppose that it will be like cookies and the list will stay with a particular machine. I wonder if there's a way to share that in the same way that you can share links in multiple Chrome copies if you are logged in to Google on each?

Thanks again. This will be a help.

James

13omargosh
Jan 28, 2014, 12:33am

#12 by Keeline>
I meant that I believe there are ~42000 unique strings, none equal to any others ("Ghostwriter" being #2907, the others being ≠ "Ghostwriter"). I could be flat wrong, but I did run some tests to test my hypothesis. For example, saving a role with selected option's HTML as:
<option value="Ghostwriter">Ghostwriter</option>
returns (on subsequent page loads):
<option value="num_2907">Ghostwriter</option>
But saving a role with a number/role mismatch (which I had to force):
<option value="num_205">Ghostwriter</option>
returns as:
<option value="num_205">defendant.</option>
despite the text previously inside <option></option>. And my weird testing roles, e.g. "single'quote", were returning numbers in the 42000s. But for all I know there are big gaps. And certainly many of them are probably spelling errors, false starts, etc.

As for your other question, maybe you could ask Tim to provide a site cookie to remember your custom role values? ;-) Or I suppose you could try editing the script to instead access your roles from a cookie on keeline.com (and work out an cross-site issues)? Or there are apparently also people working on remoteStorage. Of course, when switching computers/browsers, you still have to get the script into that browser again. And of course, all of my above suggestions are way harder than just retyping your changes one the script is installed again. :-)

14Keeline
Jan 28, 2014, 9:07am

It is not a problem for me since I use this machine for my LT work. I'm beginning to see more examples where users are portrayed as beginning a task on one device/location and continuing it on one or more others. It's tricky to coordinate, I know. If it was a session variable, on the server, then it could be used wherever the user is logged in. Cookies and other forms of local storage are typically tied to a particular machine and browser.

If there is an effort to coalesce values as you suggest, 42,000 is a lot of roles. That is approaching the hypothetical vocabulary size for people like Shakespeare. I'm sure that multiple languages and perhaps even capitalization may be factors that add to the variety. It seemed likely to me that if I used a term 1,000 times (such as "pseud.") and others used the inconvenient stock feature that the number could grow. Indeed, one might expect it to be much larger. I did not try to view the HTML for the select list and am interested in your observations from doing so.

James

15omargosh
Jan 28, 2014, 12:26pm

The session variable would still need to come from LT, no? (And sorry, my mention of cookies when you're asking about cross-machine/browser implementation probably just reveals my n00b ignorance. So much of this JS coding I'm just learning as I go along.) I'm not sure that I have any other interesting observations about the dropdown HTML that I haven't already mentioned.

When I thought about it again, with 87,000,000 books, 42,000 unique strings doesn't seem unreasonable. As an experiment, I generated roles 200 through 299 in a test book:

A; Avec la contribution de; R; Producer; O; defendant.; reporter.; 原著; Commentaires; illustrator.; joint tr.; executive production,; Einleitung; Vorwort; col.; pr.; ed.lit.; イラスト; Joint Author.; Ed. And Tr.; (KÄÄnt.); Calligrapher; Couleurs; Ill; Production.; Writing.; Cast.; Joint Comp.; Joint Ed.; 138; 5; Design; xxxNEWROLLxxx; Translator.; Engraver.; Printer.; Publisher.; Donor.; Comp.; Supposed Author.; Sir.; Inscriber.; Photographer.; Red.; Overs.; Fotogr.; Trl; Defendant.; (Kuv.); (Toim.); Bildered.; (Esitt.); Innl.; Joint Editor.; RedaktøR; Forf.; Editor.; Prface; reader; (Knt.).; xxxOTHERxxx; Medarb.; Cover Art; Illustr.; Nachwort; Series in Figures; Comment; Illustrator & Photographer; Transcriptions; Layout; Transcriptions, Music Editor, & Afterword; Publisher's Foreword; Cover design; Cover photograph; Author photograph; Rememberance; Graveur; Adapted from; Joint Composer.; Revisor; Coaut.; Editor/Contributor; Associate; Contributing Editor; Contributing Editor/Contributor; contributed biography of Calvin; Assistant; Typographer; Penciller; Inker; Writer; Penciller/Inker; Essay; Translation Reviewer; Réalisateur; Adapted by

A lot of these (especially those that are already in the list, but with a trailing period) make me think they are probably library and Amazon import data coming through. And I guess it's reasonable that TPTB might think that if custom roles are too easy to enter, things could get too "messy". Still, it might be nice if there were, say, some preference page, where each user could check and uncheck from a longer list of roles (that were highly used and in LT-Approved format), and then only these would show up on that user's dropdowns. But maybe they have disdain for things like the comic-related roles, so perhaps this script is the next best thing.

16jjwilson61
Jan 28, 2014, 12:33pm

I don't think disdain is involved. Just a business decision not to spend precious programmer time on a feature that will only be used by a small subset of LT members. Or perhaps he's deferring it for the soon-to-be-released* Add Books redo.

* in two weeks.

17omargosh
Jan 28, 2014, 12:39pm

:-) Right, I keep forgetting about the imminent Add Books redo.

18henkl
Jan 28, 2014, 2:29pm

We expect it shortly.

19omargosh
Fev 17, 2014, 2:49pm

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

I've updated the script to allow you to suppress roles that are there by default (though all bets are off if you try to do something silly like suppress "Other..." :-)), and all the roles are sorted together. Screenshot of what it can now look like:

20.Monkey.
Fev 17, 2014, 3:41pm

Awesome

21Keeline
Jan 20, 2017, 2:37pm

I note that the script for GreaseMonkey / TamperMonkey is now hosted here:

https://greasyfork.org/en/scripts/11329-librarything-custom-author-roles

James