Archived Comments (locked)

in
Subscribe to Archived Comments 10 posts, 7 voices



Jesse Andrews Admin

The following is an archive of comments made before threaded discussions was implemented (November 16th, 2008)

 
zanhsieh Scriptwright

function isbn10_to_13(isbn) {
if (!isbn.match(/^([0-9]{9})[0-9xX]$/))
return false;

// sum the digits with their weights and add the checksum for the 978 prefix
sum_of_digits = 38 + 3 * (1*isbn[0] + 1*isbn[2] + 1*isbn[4] + 1*isbn[6] + 1*isbn[8]) +
1*isbn[1] + 1*isbn[3] + 1*isbn[5] + 1*isbn[7];

// divide the sum_of_digits by the modulus number (10) to find the remainder
// and then minus 10 to get the check digit
check_digit = (10 - (sum_of_digits % 10)) % 10;

// return isbn with check_digit
return '978' + isbn.match(/^([0-9]{9})[0-9xX]$/)[0] + check_digit;
}

Now the problem is %s. This function above has dependency with %s... :(

 
zanhsieh Scriptwright

Hi,

First, thank you for refactoring. This dramatically reduces the work of cracking 'the code'.

I am working on fetching Taiwanese local bookstore data (e.g. http://www.eslitebooks.com/Program/Object/BookC...), but have the problem on %s. %s means ISBN-10, not EAN-13 / ISBN-13, whereas most of Taiwanese / Chinese bookstores use EAN-13 / ISBN-13. I did some research on internet but only found perl / cgi /python implementation for two-ways convert.

Any tips?

Thanks

zh

 
Johan Sundström Script's Author

Fair, but I don't think I can do them myself due to non-competition clauses in my employment contract these days. Feel free to track down a scriptwright to do it for you, though; the script is easy to add sites to and maintain old sites covered (in case they break).

 
zoonalink User

Fantastic script - tack så mycket! What are the chances of incorporating amazon.co.uk, abebooks.co.uk, bookkoob.co.uk, play.com, bookdepository.co.uk, quartermelon.co.uk - booksites for the UK reader. CHeers

 
wsktb Scriptwright

I have updated it, added some bookstores, and bookstores country flags. http://userscripts.org/scripts/show/6079

 
Johan Sundström Script's Author

Where would you pick up ASINs and what sites would you feed them to?

 
Wulf User

Awesome script :)

I just wish it worked for ASINs (like ISBNs, but for things other than books) too...

I also wish it would include inter-library catalog systems such as MINERVA (the system for libraries in Maine.)

 
Johan Sundström Script's Author

Added. I think the comment system here at userscripts.org broke the ajaxPrice regexp of that one; I had to rewrite it to get it to work.

 
Pallando User

Here is how to add bookpool.com to the list:

{ name: 'Bookpool.com', id: 'bookpool', hostname: /\bbookpool.com$/i,
getISBN: /(?:qs|is|sm)[\/=]([0-9X]{10})(&|\?|\.|$)/i,
bookURL: 'http://www.bookpool.com/sm/%s',
ajaxPrice: /Our\s+Price(?:[^<]*<\/b[^>]*>)?[^<]*<font>]*>(?:\s*]*>)?\s*([^<]+)/i },