﻿// ==UserScript==
// @name           ESV Narrow Column
// @namespace      http://downloads.joeyday.com
// @description    Makes the ESV text narrower to facilitate easier reading.
// @include        http://gnpcb.org/esv/search/*
// @include        http://gnpcb.org/esv/browse/*
// @include        http://gnpcb.org/esv/devotions/*
// @include        http://gnpcb.org/esv/advanced.search/*
// @include        http://www.gnpcb.org/esv/search/*
// @include        http://www.gnpcb.org/esv/browse/*
// @include        http://www.gnpcb.org/esv/devotions/*
// @include        http://www.gnpcb.org/esv/advanced.search/*
// ==/UserScript==
document.body.style.width = "32em";
document.body.style.margin = "0 auto";
GM_addStyle("body { font-family: Lucida Grande, Verdana, Arial, Helvetica, sans-serif; }");
GM_addStyle("div.header { display: none; visibility: hidden; width: 0; height: 0; margin: 0; padding: 0; }");
GM_addStyle("div.navigation { display: none; visibility: hidden; width: 0; height: 0; margin: 0; padding: 0; }");
GM_addStyle("div.main { margin-top: 1em; -moz-border-radius: 1em; background: none; }");
GM_addStyle("div.content { -moz-border-radius: 1em; padding: 1.5em 2.5em 0.9em; }");
GM_addStyle("div.bottom-navigation { display: none; visibility: hidden; width: 0; height: 0; margin: 0; padding: 0; }");
GM_addStyle("td.more-info { visibility: hidden; display: none; height: 0; width: 0; margin: 0; padding: 0; }");
GM_addStyle("td.other-products { visibility: hidden; display: none; height: 0; width: 0; margin: 0; padding: 0; }");
GM_addStyle("span.chapter-num { font-size: 60%; font-family: Lucide Grande, Verdana, Arial, Helvetica, sans-serif; vertical-align: text-bottom; color: #666; font-weight: normal; padding-right: 0; margin-right: -0.1em; }");
GM_addStyle("span.verse-num { font-size: 60%; font-family: Lucide Grande, Verdana, Arial, Helvetica, sans-serif; vertical-align: text-bottom; color: #666; font-weight: normal; padding-right: 0; margin-right: -0.1em; }");
GM_addStyle("h2 { margin-top: 0; margin-bottom: 1em; font-size: 200%; line-height: 1em; text-align: center; }");
GM_addStyle("h2 object { visibility: hidden; display: none; width: 0; height: 0; margin: 0; padding: 0; }");
GM_addStyle("span.surrounding-chapters { font-size: 40%; }");
GM_addStyle("span.surrounding-chapters a { text-decoration: none; }");
GM_addStyle("span.surrounding-chapters a:hover { text-decoration: underline; }");
GM_addStyle("div.esv-text { margin-top: 2em; margin-bottom: 4em; }");
GM_addStyle("h3 { margin-bottom: .5em; font-family: Lucida Grande, Verdana, Arial, Helvetica, sans-serif; }");
GM_addStyle("div.navigation { font-family: Lucida Grande, Verdana, Arial, Helvetica, sans-serif; }");
GM_addStyle("span.footnote, span.footnote-ref { font-family: Lucida Grande, Verdana, Arial, Helvetica, sans-serif; padding-right: 0; margin-right: 0; margin-left: -0.2em; }");
GM_addStyle("span.footnote a { text-decoration: none; font-weight: bold; font-size: 85%; vertical-align: text-bottom; }");
GM_addStyle("span.footnote a:hover { text-decoration: underline; }");
GM_addStyle("div.footnotes { font-size: 75%; width: auto; border-top: 1px dotted #69c; border-bottom: 1px dotted #69c; padding: 1em; margin-top: 2.5em; margin-bottom: 0.8em; }");
GM_addStyle("div.footnotes h3 { font-size: 160%; margin-bottom: 0.5em; }");
GM_addStyle("div.footnotes span.footnote { margin-right: 0.5em; }");
GM_addStyle("p { margin-top: 0; margin-bottom: .6em; }");
GM_addStyle("div.passage-bottom-navigation { visibility: hidden; display: none; height: 0; width: 0; margin: 0; padding: 0; }");
GM_addStyle("p.surrounding-chapters-bottom { font-size: 80%; text-align: center; margin-top: 2.5em; margin-bottom: 0.75em; }");
GM_addStyle("p.surrounding-chapters-bottom a { text-decoration: none; }");
GM_addStyle("p.surrounding-chapters-bottom a:hover { text-decoration: underline; }");
GM_addStyle("div.copyright { width: 100%; background: #666; color: #ddd; font-size: 60%; padding: 0; margin: 0; }");
GM_addStyle("div.copyright p { margin: 2em; }");
GM_addStyle("div.copyright a { color: #ddd; }");
GM_addStyle("div.signature { float: left; width: 169px; margin-top: 1em; margin-left: 0.2em; }");
GM_addStyle("div.errors { margin-top: 1em; margin-bottom: 1em; }");
GM_addStyle("a:visited { color: #06c; }");

(function() {
  var replacements, regex, key, textnodes, node, s; 

  replacements = {
    
    "<<": "←",
    ">>": "→",
    "\\|": "·",
    "\\[([0-9]*)\\]": "$1",
    
    };

regex = {}; 
for (key in replacements) { 
    regex[key] = new RegExp(key, 'g'); 
} 

textnodes = document.evaluate( "//body//text()", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); 

for (var i = 0; i < textnodes.snapshotLength; i++) { 
    node = textnodes.snapshotItem(i); 
    s = node.data; 
    for (key in replacements) { 
        s = s.replace(regex[key], replacements[key]); 
    } 
    node.data = s; 
} 

})();
