Also see Install.
1 // ==UserScript==
2 // @name Terror Island Enhancer
3 // @namespace http://freecog.net/2006/
4 // @description Shows the "title text" for comics below the comic.
5 // @include http://terrorisland.net/
6 // @include http://www.terrorisland.net/
7 // @include http://terrorisland.net/strips/*.html
8 // @include http://www.terrorisland.net/strips/*.html
9 // ==/UserScript==
10
11 Array.slice(document.getElementsByTagName('span')).filter(function(node) {
12 return node.className.match(/(^|\s)rss-content(\s|$)/);
13 }).forEach(function insert_p(node) {
14 var img = node.getElementsByTagName('img')[0];
15 if (!img || !img.title) return;
16 var p = document.createElement('p');
17 with (p.style) {
18 padding = '0';
19 margin = '-3px auto 0 auto';
20 backgroundColor = '#ddd';
21 color = 'black';
22 width = (img.width - 4*2) + 'px';
23 borderBottom = borderLeft = borderRight = '1px solid black';
24 padding = '4px';
25 fontSize = '14px';
26 minHeight = '34px'; // Don't shift the nav around so much.
27 }
28 function set_width() {
29 p.style.width = (img.width - 4*2) + 'px';
30 }
31 set_width();
32 // If the image hasn't loaded, make sure that the paragraph's width
33 // is set correctly when it does.
34 img.addEventListener('load', set_width, false);
35 p.appendChild(document.createTextNode(img.title));
36 if (img.nextSibling) {
37 img.parentNode.insertBefore(p, img.nextSibling);
38 } else {
39 img.parentNode.appendChild(p);
40 }
41 });
© 2004–2010 Tom W. Most