<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dw="https://www.dreamwidth.org">
  <id>tag:dreamwidth.org,2009-05-04:266577</id>
  <title>terriko</title>
  <subtitle>terriko</subtitle>
  <author>
    <name>terriko</name>
  </author>
  <link rel="alternate" type="text/html" href="https://terriko.dreamwidth.org/"/>
  <link rel="self" type="text/xml" href="https://terriko.dreamwidth.org/data/atom"/>
  <updated>2013-10-19T18:47:44Z</updated>
  <dw:journal username="terriko" type="personal"/>
  <entry>
    <id>tag:dreamwidth.org,2009-05-04:266577:138949</id>
    <link rel="alternate" type="text/html" href="https://terriko.dreamwidth.org/138949.html"/>
    <link rel="self" type="text/xml" href="https://terriko.dreamwidth.org/data/atom/?itemid=138949"/>
    <title>Book review code</title>
    <published>2013-10-17T23:33:27Z</published>
    <updated>2013-10-19T18:47:44Z</updated>
    <category term="book"/>
    <category term="homepage"/>
    <category term="code"/>
    <category term="javascript"/>
    <category term="hack"/>
    <dw:security>public</dw:security>
    <dw:reply-count>0</dw:reply-count>
    <content type="html">One of the things that bugs me when I'm doing book reviews is that I prefer it when reviews have a picture of the cover and link to the book of some sort, but I didn't love the output from Amazon's referal link generator, which would have been the easiest solution.  I've been doing it manually, but that's a lot of cut and pasting and I kind of abhor doing tasks that are easy to automate.&lt;br /&gt;&lt;br /&gt;Thankfully, I'm a coder and a user of greasemonkey, so I have all the skills I need to automate it.  Seriously, being able to tweak web pages to suit my own needs is the greatest thing.  &lt;br /&gt;&lt;br /&gt;In the spirit of sharing, here's the script I'm using to generate the code I wanted for my reviews using the book page on LibraryThing:&lt;br /&gt;&lt;br /&gt;&lt;pre style="color:#000000;background:#ffffff;"&gt;
&lt;span style="color:#3f7f59; "&gt;// ==UserScript==&lt;/span&gt;
&lt;span style="color:#3f7f59; "&gt;// @name        Book review header generator&lt;/span&gt;
&lt;span style="color:#3f7f59; "&gt;// @namespace   tko-bookreview&lt;/span&gt;
&lt;span style="color:#3f7f59; "&gt;// @description Takes any librarything book page and gives me a nice link to the book with cover and author details&lt;/span&gt;
&lt;span style="color:#3f7f59; "&gt;// @include     &lt;/span&gt;&lt;span style="color:#3f3fbf; "&gt;http://www.librarything.com/work/&lt;/span&gt;&lt;span style="color:#3f7f59; "&gt;*&lt;/span&gt;
&lt;span style="color:#3f7f59; "&gt;// @version     1&lt;/span&gt;
&lt;span style="color:#3f7f59; "&gt;// @grant       none&lt;/span&gt;
&lt;span style="color:#3f7f59; "&gt;// ==/UserScript==&lt;/span&gt;

&lt;span style="color:#3f7f59; "&gt;// Get all the data we'd like to display at the top of a review&lt;/span&gt;
var coverimage = document.getElementById(&lt;span style="color:#ffffff; background:#660099; font-weight:bold; font-style:italic; "&gt;'mainCover'&lt;/span&gt;).outerHTML;
var title = document.getElementsByTagName(&lt;span style="color:#2a00ff; "&gt;'h1'&lt;/span&gt;)[0].innerHTML;
var author = document.getElementsByTagName(&lt;span style="color:#2a00ff; "&gt;'h2'&lt;/span&gt;)[0].innerHTML;
var librarythinglink = document.URL; 


&lt;span style="color:#3f7f59; "&gt;// Trim down the title and author info&lt;/span&gt;
title = title.&lt;span style="color:#7f0055; font-weight:bold; "&gt;replace&lt;/span&gt;(/ *&amp;lt;span .*&amp;lt;\/span&amp;gt;/, &lt;span style="color:#ffffff; background:#660099; font-weight:bold; font-style:italic; "&gt;''&lt;/span&gt;);

author = author.&lt;span style="color:#7f0055; font-weight:bold; "&gt;replace&lt;/span&gt;(/href=&lt;span style="color:#2a00ff; "&gt;"&lt;/span&gt;&lt;span style="color:#2a00ff; "&gt;/, 'href=&lt;/span&gt;&lt;span style="color:#2a00ff; "&gt;"&lt;/span&gt;http:&lt;span style="color:#3f7f59; "&gt;//&lt;/span&gt;&lt;span style="color:#3f3fbf; "&gt;www.librarything.com&lt;/span&gt;&lt;span style="color:#3f7f59; "&gt;');&lt;/span&gt;
author = author.&lt;span style="color:#7f0055; font-weight:bold; "&gt;replace&lt;/span&gt;(/&amp;lt;hr&amp;gt;/, &lt;span style="color:#ffffff; background:#660099; font-weight:bold; font-style:italic; "&gt;''&lt;/span&gt;);

&lt;span style="color:#3f7f59; "&gt;// Generate the code for this book&lt;/span&gt;
var reviewheader = &lt;span style="color:#ffffff; background:#660099; font-weight:bold; font-style:italic; "&gt;'&amp;lt;a href="'&lt;/span&gt; + librarythinglink + &lt;span style="color:#2a00ff; "&gt;'"&amp;gt;'&lt;/span&gt; + 
   coverimage + &lt;span style="color:#ffffff; background:#660099; font-weight:bold; font-style:italic; "&gt;'&amp;lt;br /&amp;gt;'&lt;/span&gt; +
   &lt;span style="color:#2a00ff; "&gt;'&amp;lt;b&amp;gt;'&lt;/span&gt; + title + &lt;span style="color:#ffffff; background:#660099; font-weight:bold; font-style:italic; "&gt;'&amp;lt;/b&amp;gt;&amp;lt;/a&amp;gt; '&lt;/span&gt; +
   &lt;span style="color:#2a00ff; "&gt;'&amp;lt;em&amp;gt;'&lt;/span&gt; + author + &lt;span style="color:#ffffff; background:#660099; font-weight:bold; font-style:italic; "&gt;'&amp;lt;/em&amp;gt;'&lt;/span&gt;;

&lt;span style="color:#3f7f59; "&gt;// Add code around this for embedding it into the page&lt;/span&gt;
var textbox = &lt;span style="color:#ffffff; background:#660099; font-weight:bold; font-style:italic; "&gt;'&amp;lt;h4&amp;gt;Review Code&amp;lt;/h4&amp;gt;'&lt;/span&gt; +
	&lt;span style="color:#ffffff; background:#660099; font-weight:bold; font-style:italic; "&gt;'&amp;lt;textarea name="embedHTML" onFocus="this.select();" rows="5" '&lt;/span&gt; + 
	&lt;span style="color:#ffffff; background:#660099; font-weight:bold; font-style:italic; "&gt;'style="width: 250px;" wrap="virtual"&amp;gt;'&lt;/span&gt; + reviewheader + &lt;span style="color:#ffffff; background:#660099; font-weight:bold; font-style:italic; "&gt;'&amp;lt;/textarea&amp;gt;'&lt;/span&gt;;


&lt;span style="color:#3f7f59; "&gt;// Find a good spot and add it to the page&lt;/span&gt;
var insert = document.getElementsByClassName(&lt;span style="color:#2a00ff; "&gt;'gap'&lt;/span&gt;)[0];
insert.outerHTML =  textbox + insert.outerHTML;
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Please feel free to consider this open sourced and free for any type of use: alter it to suit your needs as you will!&lt;br /&gt;&lt;br /&gt;Edit: &lt;a href="https://github.com/terriko/webscripts"&gt;Github link&lt;/a&gt;, for those so inclined.&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=terriko&amp;ditemid=138949" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
  <entry>
    <id>tag:dreamwidth.org,2009-05-04:266577:13657</id>
    <link rel="alternate" type="text/html" href="https://terriko.dreamwidth.org/13657.html"/>
    <link rel="self" type="text/xml" href="https://terriko.dreamwidth.org/data/atom/?itemid=13657"/>
    <title>Coding brain != reading brain?</title>
    <published>2009-10-14T04:17:21Z</published>
    <updated>2009-10-14T04:17:21Z</updated>
    <category term="code"/>
    <category term="photo"/>
    <category term="geek"/>
    <category term="javascript"/>
    <dw:security>public</dw:security>
    <dw:reply-count>12</dw:reply-count>
    <content type="html">The exhaustion/stress from fixing crud and trying to get my thesis done at the same time hit me hard today, so I came home at 4pm and immediately fell asleep. &lt;br /&gt;&lt;br /&gt;As these things usually go, this resulted in me awakening sometime later, still feeling like a zombie, but unable to go back to sleep.  I completely failed to read a magazine because I found myself skimming before I'd read a couple of sentences.  So I figured I'd go mess about with flickr... time flies, and I find I've written a greasemonkey script making it easier for me to blog photos.  Which is fine, except how the heck does it work that I can't concentrate long enough to read two sentences, yet I can write JavaScript code just fine?&lt;br /&gt;&lt;br /&gt;I am concerned that in the dystopian future, some evil megacorp will take advantage of this and generate worker drones who are incapable of reading but perfectly good at writing code.&lt;br /&gt;&lt;br /&gt;No, wait, that's just the exhaustion talking.  In that spirit, though... Have some tentacles, and I'm going back to bed:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin: 10px;"&gt;&lt;a href="http://www.flickr.com/photos/terrio/4004840733/" title="Tentacles"&gt;&lt;img src="http://farm4.static.flickr.com/3525/4004840733_bc375a792a.jpg" alt="Tentacles" style="border: solid 2px #000000;" /&gt;&lt;/a&gt;&lt;br /&gt; &lt;span style="font-size: 0.9em; margin-top: 0px;"&gt;&lt;a href="http://www.flickr.com/photos/terrio/4004840733/"&gt;Tentacles&lt;/a&gt;&lt;br /&gt;by &lt;a href="http://www.flickr.com/photos/terrio/"&gt;Terriko&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;&lt;br clear="all" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src="https://www.dreamwidth.org/tools/commentcount?user=terriko&amp;ditemid=13657" width="30" height="12" alt="comment count unavailable" style="vertical-align: middle;"/&gt; comments</content>
  </entry>
</feed>
