<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Discussion on Peninsula Library System - Amazon.com &amp; other sources Lookup | Userscripts.org</title>
    <link>http://userscripts.org/scripts/show/1072</link>
    <description>Recent comments on userscript: Peninsula Library System - Amazon.com &amp; other sources Lookup</description>
    <language>en-us</language>
    <ttl>60</ttl>
    <item>
      <title>Archived Comments, replied by Junk Blocker</title>
      <description>&lt;p&gt;I am just helping myself as a user of the library :) &lt;/p&gt;

&lt;p&gt;I like your facility of linking to library location and hours on the library page for the book and was thinking of implementing the same in my version this weekend too.&lt;/p&gt;</description>
      <pubDate>Thu, 12 Apr 2007 15:49:27 +0000</pubDate>
      <guid isPermaLink="false">userscripts.org:17355:75895</guid>
      <author>Junk Blocker</author>
      <link>http://userscripts.org/posts/75895</link>
    </item>
    <item>
      <title>Archived Comments, replied by Al's scripts</title>
      <description>&lt;p&gt;Thanks for helping the Peninsula Library system.  You may find this GM script interesting...&lt;/p&gt;

&lt;p&gt;Google Print - Peninsula Library System Lookup Mashup&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://userscripts.org/scripts/show/8286&quot;&gt;http://userscripts.org/scripts/show/8286&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 12 Apr 2007 06:24:06 +0000</pubDate>
      <guid isPermaLink="false">userscripts.org:17355:75896</guid>
      <author>Al's scripts</author>
      <link>http://userscripts.org/posts/75896</link>
    </item>
    <item>
      <title>Archived Comments, replied by Junk Blocker</title>
      <description>&lt;p&gt;The sample code paste below for Gary Bobcat got messed up. The script on this page is fine :)&lt;/p&gt;</description>
      <pubDate>Fri, 30 Mar 2007 04:04:49 +0000</pubDate>
      <guid isPermaLink="false">userscripts.org:17355:75897</guid>
      <author>Junk Blocker</author>
      <link>http://userscripts.org/posts/75897</link>
    </item>
    <item>
      <title>Archived Comments, replied by Junk Blocker</title>
      <description>&lt;p&gt;The code here got messed up while posting. See &lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://userscripts.org/forums/1/topics/200?page=1#posts-862&quot;&gt;http://userscripts.org/forums/1/topics/200?page...&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;for actual code.&lt;/p&gt;</description>
      <pubDate>Fri, 30 Mar 2007 04:03:00 +0000</pubDate>
      <guid isPermaLink="false">userscripts.org:17355:75898</guid>
      <author>Junk Blocker</author>
      <link>http://userscripts.org/posts/75898</link>
    </item>
    <item>
      <title>Archived Comments, replied by Junk Blocker</title>
      <description>&lt;p&gt;Attempting to paste the code for the initial attempt.&lt;/p&gt;

&lt;p&gt;&lt;pre&gt;
// ==UserScript==
// @name        Timerbland Regional Library Catalog - Amazon.com &amp;amp; other sources Lookup
// @description Display the availability of a book in the Timberland Regional Library Catalog (WA, USA) on amazon.com, other bookstores and wikipedia book pages
// @namespace   http://loonyone.livejournal.com
// @include     *abebooks.com/*
// @include     *alibris.com/*
// @include     *amazon.*/*
// @include     *barnesandnoble.com/*
// @include     *bookfinder.com/*
// @include     *books.google.com/*
// @include     *booksamillion.com/*
// @include     *bookshelved.org/*
// @include     *bookmooch.com/*
// @include     *bordersstores.com/*
// @include     *buy.com/*
// @include     *c2.com/*
// @include     *half.ebay.com/*
// @include     *librarything.com/work/*
// @include     *mitpress.mit.edu/*
// @include     *penguin.*/*
// @include     *penguingroup.*/*
// @include     *penguinbooksindia.*/*
// @include     *penguincatalogue.*/*
// @include     *powells.com/*
// @include     *wikipedia.org/*isbn=*
// @include     *worldcat.org/*
// @include     *worldcatlibraries.org/*
// @creator     Manpreet Singh |junkblocker&amp;lt;at&gt;yahoo&amp;lt;/at&gt;&amp;lt;dot&gt;com|
// @source      http://userscripts.org/scripts/show/1072
// @identifier  http://userscripts.org/scripts/source/1072.user.js
// @version     0.1
// @date        2007-03-11
// ==/UserScript==

// Initially based on Peninsula Library System lookup script
// Work on most sites. More specifically at least on *abebooks.com/*,
// *alibris.com/*, *amazon.*/*, *barnesandnoble.com/*, *bookfinder.com/*,
// *books.google.com/*, *booksamillion.com/*, *bookmooch.com/*,
// *bordersstores.com/*, *buy.com/*, *c2.com/*, *half.ebay.com/*,
// *librarything.com/work/*, *penguin.*/*, *penguingroup.*/*,
// *penguinbooksindia.*/*, *penguincatalogue.*/*, *powells.com/*,
// *wikipedia.org/*isbn=*, *worldcat.org/* &amp;amp; *worldcatlibraries.org/*
//
// Version 0.1 - First release based on Peninsula Library System - Amazon.com &amp;amp; other sources lookup script


(function() {
  // check for updates every day
  /*
  if ((unsafeWindow || window.wrappedJSObject || window).UserScriptUpdates) {
    var lastChecked = GM_getValue('LAST_UPDATE_CHECKED', null);
    var now = new Date().getTime();
    if (!lastChecked || (now - lastChecked) &gt; 24 * 60 * 60 * 1000) {
      GM_setValue('LAST_UPDATE_CHECKED', now.toString());
      var SCRIPT = {
        name: ' Timerbland Regional Library Catalog - Amazon.com &amp;amp; other sources Lookup',
        namespace: 'http://loonyone.livejournal.com',
        description:  'Display the availability of a book in the Timberland Regional Library Catalog (WA, USA) on amazon.com, other bookstores and wikipedia book pages'
        source: 'http://userscripts.org/scripts/show/1072',
        identifier: 'http://userscripts.org/scripts/source/1072.user.js',
        version: &quot;0.1&quot;,               // version
        date: (new Date(2007, 3 - 1, 11))    // update date
            .valueOf()
      };
      try {
        (unsafeWindow || window.wrappedJSObject || window).UserScriptUpdates.requestAutomaticUpdates(SCRIPT);
      } catch (ex) {}
    }
  }
  */
  Array.prototype.addUnique = function (elem) {
    for (var i = 0, len = this.length; i &amp;lt; len; i++) {
      if (this[i] == elem) {
        return;
      }
    }
    this.push(elem);
  }
  /*
  window.alert = function (msg) {
    if (! window.confirm(msg)) {
      throw 'aborted';
    }
  }*/
  function findGenericISBN(themap) {
    var bodyhtml = document.body.innerHTML;
    while (bodyhtml.match(/ISBN(?:-1[03])?\s*[ =:]\s*(?:&amp;lt;\/?[a-zA-Z0-9]+\s*\/?&gt;)?([\n\r\s\dX-]+)((.*[\n\r]*)*)/i)) {
      var maybeMultiple = RegExp.$1;
      bodyhtml = RegExp.$2;
      while (maybeMultiple.match(/\b((?:\d{3}-?)?(?:\d{9}[\dX]|[\d-]{8,}[\dx]))([\s\n\r\dX-]*)/i)) {
        themap[RegExp.$1]='';
        maybeMultiple = RegExp.$2;
      }
    }
    try {
      themap[location.href.match(/isbn[=\/]((\d{3}-?)?\d{9}[\dX])/i)[1]] = '';
    } catch (e){}
  }
  function getISBN() {
    var results = {};
    try {
      if (location.href.match(/^https?:\/\/(www\.)?librarything\.com/)) {
        var isbns = document.evaluate(&quot;//div[@class='isbn']/a&quot;, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
        for (var i = 0, len = isbns.snapshotLength; i &amp;lt; len; i++) {
          var a = isbns.snapshotItem(i);
          if (a.innerHTML.match(/ISBN\s+((\d{3}-?)?\d{9}[\dX])/i)) {
            results[RegExp.$1] = '';
          }
        }
      } else if (location.href.match(/^https?:\/\/(www\.)?amazon\./)) {
        try {
          results[location.href.match(/(asin|product|dp)[\/=]((\d{3}-?)?\d{9}[\dX])(\/|&amp;amp;|;|\?|$)/i)[2]] = '';
        } catch (e) {}
        var thiscontent = document.body.innerHTML;
        var idx = thiscontent.indexOf('ISBN-10:');
        if (idx != -1 &amp;amp;&amp;amp; thiscontent.substring(idx+12).match(/^[\n\r\s]*((\d{3}-?)?\d{9}[\dX])/i)) {
          results[RegExp.$1] = '';
        }
        var idx = thiscontent.indexOf('ISBN-13:');
        if (idx != -1 &amp;amp;&amp;amp; thiscontent.substring(idx+12).match(/^[\n\r\s]*((\d{3}-?)?\d{9}[\dX])/i)) {
          results[RegExp.$1] = '';
        }
      } else if (location.href.match('abebooks.com')) {
        try {
          results[document.title.match(/ISBN ((\d{3}-?)?\d{9}[\dX])/i)[1]] = '';
        } catch (e) {};
        try {
          results[document.body.innerHTML.match(/class=&quot;isbn&quot;&gt;((\d{3}-?)?\d{9}[\dX])/i)[1]] = '';
        } catch (e) {};
      } else if (location.href.match('buy.com')) {
        results[document.title.match(/ISBN ((\d{3}-?)?\d{9}[\dX])/i)[1]] = '';
      } else if (location.href.match('powells.com')) {
        findGenericISBN(results);
        var dts = document.getElementsByTagName('dt');
        for (var i=0; i&amp;lt;dts&gt;&amp;lt;bs&gt;&lt;b&gt; ISBN &lt;/b&gt; ' + isbn;
      for (var i = 0, len = avails.length; i &amp;lt; len; i++) {
        var hrefTitle = avails[i][0];
        var theColor = avails[i][1];
        var thislink = document.createElement('a');
        with (thislink) {
          href = libraryUrlPattern + isbn + libraryUrlPatternSuffix;
          alt = hrefTitle;
          title = hrefTitle;
          textContent = hrefTitle;
        }
        with (thislink.style) {
          display = 'block';
          border = 'outset thin black';
          padding = '2px';
          textAlign = 'center';
          color = 'white';
          fontWeight = 'bold';
          background = theColor;
          textDecoration = 'none';
          fontFamily = 'arial,sans';
          margin = '0px 0px 3px';
        }
        thespan.appendChild(thislink);
      }
      divStyled.appendChild(thespan);
      if (!maindiv) {
        maindiv = document.createElement('div');
        maindiv.id = 'trlcdiv';
        with (maindiv.style) {
          left = '200px';
          top = '6px';
          zIndex = '999';
          border = '1px solid #000033';
          color = 'black';
          padding = '0px';
          position = 'absolute';
          opacity = '0.95';
          textAlign = 'left';
        }

        var title = document.createElement('div');
        with (title.style) {
          background = 'rgb(153,204,255)';
          border = 'solid';
          borderWidth = '0px 0px 1px';
          cursor = 'move';
          fontFamily = 'dialog,arial,sans';
          fontSize = '12px';
          fontWeight = 'bold';
          padding = '3px 0px 2px 15px';
          textAlign = 'right';
        }
        title.appendChild(document.createTextNode(' ' + libraryName + ' '));
        var closeButton = document.createElement('a');
        closeButton.href = 'javascript: closeTRLC();';
        closeButton.innerHTML = 'X';
        with (closeButton.style) {
          display = 'inline';
          padding = '2px 6px 1px';
          color = 'white';
          cursor = 'pointer';
          textDecoration = 'none';
          border = 'solid 1px white';
          background = '#069';
        }
        title.appendChild(closeButton);

        maindiv.appendChild(title);
        body.appendChild(maindiv);
        title.drag = new Drag(title, maindiv);
      }
      maindiv.appendChild(divStyled);
    },

    doLookup : function (isbns) {
      var makeCallback = function(isobune) {
        return function(results) {
          page = results.responseText;
          var availTypes = [];
          if (notFound.test(page)) {
            var due = page.match(notFound)[1];
            availTypes.addUnique([&quot;Not available.&quot; , &quot;#f66&quot;]);
          } else {
            if (libraryAvailability.test(page)) {
              availTypes.addUnique([&quot;On the shelf now!&quot; , &quot;#00cc66&quot;]);
            }
            if (libraryCheckedOut.test(page)) {
              availTypes.addUnique([&quot;Checked out&quot; , &quot;orange&quot;]);
            }
            if (libraryTransit.test(page)) {
              availTypes.addUnique([&quot;Transit Request&quot; , &quot;orange&quot;]);
            }
          }
          if (!availTypes.length) {
            while (page.match(/(?:white|FCFDC|ormation)&quot;&gt;(.+)&amp;lt;\/a&gt;((.*[\n\r]*)*)/i)) {
              var extraType = RegExp.$1;
              page = RegExp.$2;
              extraType = extraType.replace(/&amp;lt;!--.*--&gt;/g,'');
              extraType = extraType.replace(/.nbsp;/g, ' ');
              extraType = extraType.replace(/^\s+/, '');
              extraType = extraType.replace(/\s+$/, '');
              availTypes.addUnique([extraType, &quot;orange&quot;]);
            }
          }
          if (!availTypes.length) {
            availTypes.addUnique([&quot;Error: Click for library page. You can check by searching manually.&quot; , &quot;red&quot;]);
          }
          libraryLookup.insertLinks (isobune, availTypes);
        };
      };
      for (var isbn in isbns) {
        GM_log(libraryUrlPattern + isbn + libraryUrlPatternSuffix);
        GM_xmlhttpRequest ({method : 'GET', url : libraryUrlPattern + isbn + libraryUrlPatternSuffix, onload : makeCallback(isbn)});
      }
    }
  }

  try {
    libraryLookup.doLookup(thisisbn);
    var head = document.getElementsByTagName('head');
    if (head &amp;amp;&amp;amp; head[0]) {
      var s = document.createElement('script');
      s.language='javascript';
      s.type = 'text/javascript';
      s.text = 'function closeTRLC(){try{document.getElementById(&quot;trlcdiv&quot;).style.display=&quot;none&quot;}catch(e){}}';
      head[0].appendChild(s);
    }
  } catch (e) {
    return;
  }
}
)();
&amp;lt;/dot&gt;&lt;/pre&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 12 Mar 2007 05:57:16 +0000</pubDate>
      <guid isPermaLink="false">userscripts.org:17355:75899</guid>
      <author>Junk Blocker</author>
      <link>http://userscripts.org/posts/75899</link>
    </item>
    <item>
      <title>Archived Comments, replied by Junk Blocker</title>
      <description>&lt;p&gt;Thank you. &lt;/p&gt;

&lt;p&gt;I was able to modify the script to do some minimal checking but a full fledged new library takes a lot of work to create and more importantly to maintain. You should try asking for this on the forums and I'll be glad to send my initial attempt.&lt;/p&gt;</description>
      <pubDate>Mon, 12 Mar 2007 05:39:17 +0000</pubDate>
      <guid isPermaLink="false">userscripts.org:17355:75900</guid>
      <author>Junk Blocker</author>
      <link>http://userscripts.org/posts/75900</link>
    </item>
    <item>
      <title>Archived Comments, replied by Gary Bobcat</title>
      <description>&lt;p&gt;Very nice script, particularly in the number of sites covered. I don't know how to make scripts yet or else I would try to do this myself. Would you be able to modify yours for Timberland Regional Library in Western WA? &lt;a href=&quot;http://www.timberland.lib.wa.us/&quot;&gt;http://www.timberland.lib.wa.us/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for your consideration. I would notify TRL  of its existence if you do.&lt;/p&gt;</description>
      <pubDate>Mon, 12 Mar 2007 00:05:53 +0000</pubDate>
      <guid isPermaLink="false">userscripts.org:17355:75901</guid>
      <author>Gary Bobcat</author>
      <link>http://userscripts.org/posts/75901</link>
    </item>
    <item>
      <title>Archived Comments, replied by Jesse Andrews</title>
      <description>&lt;p&gt;The following is an archive of comments made before threaded discussions was implemented (November 16th, 2008)&lt;/p&gt;</description>
      <pubDate>Wed, 17 Nov 2004 01:05:48 +0000</pubDate>
      <guid isPermaLink="false">userscripts.org:17355:75894</guid>
      <author>Jesse Andrews</author>
      <link>http://userscripts.org/posts/75894</link>
    </item>
  </channel>
</rss>
