freecog.net

titantv.user.js

Also see Install.

   1 // A TitanTV redesign has made this script obsolete.  As I find myself using
   2 // TitanTV less and less since the school year began, I do not intend to 
   3 // update it.  In its place, I recommend using "Remove ads from TitanTv" which
   4 // does much of what this script did.
   5 //  --Tom, Dec 17, 2006
   6 
   7 // ==UserScript==
   8 // @name           TitanTV Zeus -- smiting the beast!
   9 // @namespace      http://freecog.net/2006/
  10 // @description    Removes ads and excess chrome from the TitanTV grid.  Also restyles the listings table to be a bit more low-key.  (I could use some help from a real designer here, my color scheme isn't much of an imrovement.)  Grid listings are given logical class names, so targeting them from userContent.css should be much easier (again, if you have a good color scheme, please contact me!).  Finally, listings are filtered based on their text content (you will likely want to edit this part to your tastes).
  11 // @include        *.titantv.com/ttv/Grid/grid.aspx
  12 // ==/UserScript==
  13 
  14 (function(){
  15 
  16 // EDIT THIS:
  17 var filterStrings = [
  18     'Off-Air', // PBS
  19     'Paid Programming',
  20     'Infomercials',
  21     '(Religious', // The whole category
  22     'Jack Van Impe Presents', // Not real news
  23     'Fox News Sunday', // Ditto
  24     'Insider(News)', // Again
  25     'Web Junk', // Called 'junk' for a reason
  26     'I Love the \'70s',
  27     'Golf',
  28     'Maximum Exposure',
  29     'Reba',
  30     'Big Brother',
  31     'Auto Racing',
  32     'Elimidate',
  33     'Entertainment Tonight',
  34     'Access Hollywood',
  35     'Sportsman Channel',
  36     'People\'s Court',
  37     'Divorce Court',
  38     'Judge Alex',
  39     'Maury',
  40     'Tyra Banks',
  41     'The View',
  42     'Judge Mathis',
  43     'Judge Joe Brown',
  44     'Judge Judy',
  45     'Eye for an Eye',
  46     'Judge Hatchett',
  47     'Home Shopping',
  48     'My Wife and Kids', // Annoying
  49     'Everybody Loves Raymond', // HATEHATEHATEHATEHATE!!!
  50     'The Parkers',
  51     'Blind Date',
  52     'Inside Edition',
  53     'Ellen DeGeneres', // HATEHATEHATEHATEHATE!!!
  54     'Tony Danza Show', // DIEDIEDIEDIEDIE!!!
  55     'Oprah Winfrey', // Best of the bunch.
  56     'Yes, Dear',
  57     'Bernie Mac',
  58     '8 Simple Rules',
  59     'Wheel of Fortune',
  60     'Dukes of Hazzard', // Dead boring
  61     'CSI: Miami',
  62     'EntertainmentStudios.com', // WTF?
  63     'King of Queens',
  64     'Will & Grace',
  65     'Supernanny',
  66     'Wife Swap',
  67     'Who Wants to Be a Millionaire',
  68     'Roseanne',
  69     'Cheaters',
  70     'Sex and the City',
  71     'America\'s Funniest Home Videos',
  72     'Next(Game)',
  73 ];
  74 
  75 
  76 var hasRun = false;
  77 var removeIDs = [
  78     'leaderboard',
  79     'leaderboard',
  80     'footernav',
  81     'footer'
  82 ];
  83 
  84 // Color scheme:
  85 // http://wellstyled.com/tools/colorscheme2/index-en.html?tetrad;84;0;150;0.3;-0.8;0.3;0.5;0.1;0.9;0.5;0.75;0.3;-0.8;0.3;0.5;0.1;0.9;0.5;0.75;0.3;-0.8;0.3;0.5;0.1;0.9;0.5;0.75;0.3;-0.8;0.3;0.5;0.1;0.9;0.5;0.75;0
  86 
  87 var stylesheet = [
  88     '.general { background-color: #FFF2E6; }',
  89     '.action, .c1 { background-color: #FFEF80; }',
  90     '.children, .c2 { background-color: #E6FFBF; }',
  91     '.comedy, .c3 { background-color: #BFE3FF; }',
  92     '.drama, .c4 { background-color: #FFBFEF; }',
  93     '.educational, .c6 { background-color: #F5FFE6; }',
  94     '.game, .c7 { background-color: #CFDCE6; }',
  95     '.music, .c9 { background-color: #FFE6F9; }',
  96     '.nature, .c10 { background-color: #CCFF80; }',
  97     '.news, .c11 { background-color: #E6CFE0; }',
  98     '.talk { background-color: #E6F4FF; }',
  99     '.soap { background-color: #FFC080; }',
 100     '.documentary { background-color: #80C8FF; }',
 101     '.sports { background-color: #efe9a1; }', // Default
 102     '.how-to { background-color: #ffe1ff; }', // Default
 103     '.religious { background-color: #f3fff0; }', // Default
 104     '.sci-fi { background-color: #bac8f3; }',
 105     
 106     '.filtered > * { visibility: hidden; }',
 107     
 108     'td.filtered:hover > * {',
 109         'visibility: visible !important;',
 110         'opacity: .5;',
 111     '}',
 112     
 113     '.filtered + .filtered {',
 114         'border-left-width: 0;',
 115     '}',
 116     
 117     // Hide that stupid little ad in the tabs
 118     'td.gridbutton iframe {',
 119         'display: none !important;',
 120     '}',
 121     
 122     'td.gC a img {',
 123         'opacity: .2;',
 124     '}',
 125     'td.gC:hover a img {',
 126         'opacity: .6;',
 127     '}',
 128     
 129     '.gridTable, .gridTable td {',
 130         'border-color: #596F80 !important;',
 131     '}',
 132 ].join(' ');
 133 
 134 var colorClasses = {
 135     "#eeeee0": "general",
 136     "#ffec8b": "action",
 137     "#dbf0fc": "children",
 138     "#c5e6ff": "comedy",
 139     "#ffbbff": "drama",
 140     "#eee9bf": "educational",
 141     "#ffe4e1": "game",
 142     "#ffe4c4": "music",
 143     "#d7ead8": "nature",
 144     "#eecbad": "news",
 145     "#c1cdc1": "talk",
 146     "#ffc1c1": "soap",
 147     "#e0dbef": "documentary",
 148     "#efe9a1": "sports",
 149     "#ffe1ff": "how-to",
 150     "#f3fff0": "religious",
 151     "#bac8f3": "sci-fi",
 152 };
 153 
 154 
 155 function main() {
 156     if (hasRun) return;
 157     hasRun = true;
 158     var n;
 159     
 160     for (var i = 0; i < removeIDs.length; i++) {
 161         n = document.getElementById(removeIDs[i]);
 162         n.parentNode.removeChild(n);
 163     }
 164     
 165     n = document.getElementById('adbar');
 166     n.parentNode.parentNode.removeChild(n.parentNode);
 167     
 168     var nodes = unsafeWindow.document.evaluate(
 169         '//td[@class="gridBannerRowCell"]/..', 
 170         unsafeWindow.document.body, null, 
 171         XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
 172 
 173     n = nodes.iterateNext();
 174     var toRemove = [];
 175     while (n) {
 176         toRemove.push(n);
 177         n = nodes.iterateNext();
 178     }
 179     for (var i = 0; i < toRemove.length; i++) {
 180         toRemove[i].parentNode.removeChild(toRemove[i]);
 181     }
 182 
 183     // Change styled buttons to normal ones
 184     //   Not that they're really all that ugly, but the lack
 185     //   of hover and especially "clicked" states drives me crazy.
 186     var iterator = unsafeWindow.document.evaluate(
 187         '//input[@class="buttonblue"]', 
 188         unsafeWindow.document.body, null, 
 189         XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
 190     var nodes = [];
 191     n = iterator.iterateNext();
 192     while (n) {
 193         nodes.push(n);
 194         n = iterator.iterateNext();
 195     }
 196     for (var i = 0; i < nodes.length; i++) {
 197         nodes[i].className = '';
 198     }
 199     // Same for the "Go" button
 200     n = document.getElementById('ucGrid_ucQS_btnSearch');
 201     n.className = '';
 202     n.removeAttribute('style');
 203 
 204     // Switch inline colors on the grid to classes
 205     for (var k in colorClasses) {
 206         var iterator = unsafeWindow.document.evaluate(
 207             '//td[@bgcolor="' + k + '"]', 
 208             unsafeWindow.document.body, null, 
 209             XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
 210         n = iterator.iterateNext();
 211         var nodes = [];
 212         while (n) {
 213             nodes.push(n);
 214             n = iterator.iterateNext();
 215         }
 216         for (var i = 0; i < nodes.length; i++) {
 217             var n = nodes[i];
 218             n.removeAttribute('bgcolor');
 219             // These handle mouseover coloring--we replace them with a 
 220             // :hover pseudoclass.
 221             n.removeAttribute('onmouseout');
 222             n.removeAttribute('onmouseover');
 223             // Remove any inline background-color, in case the cell has
 224             // been hovered already.
 225             n.style.backgroundColor = '';
 226             n.className += ' gridCell ' + colorClasses[k];
 227             var text = n.textContent;
 228             for (var x = 0; x < filterStrings.length; x++) {
 229                 if (text.indexOf(filterStrings[x]) > -1) {
 230                     n.className += ' filtered';
 231                     break;
 232                 }
 233             }
 234         }
 235     }
 236     
 237     var s = document.createElement('style');
 238     s.appendChild(document.createTextNode(stylesheet));
 239     document.body.appendChild(s);
 240     s.setAttribute('type', 'text/css');
 241 }
 242 
 243 main();
 244 //window.addEventListener('load', main, false);
 245 
 246 })();