BBC News Relax

By Dan Atkinson Last update Mar 7, 2006 — Installed 2,106 times.
// ==UserScript==
// @name            BBC News Relax
// @namespace       Platypus
// @description			Created with Platypus to 'relax' the width on the BBC Website.
// @include http://news.bbc.co.uk/1/hi/*
// @include http://news.bbc.co.uk/2/hi/*
// @include http://news.bbc.co.uk/sport1/hi/*
// @exclude http://news.bbc.co.uk/1/hi/default.stm
// @exclude http://news.bbc.co.uk/1/hi/*/default.stm
// @exclude http://news.bbc.co.uk/2/hi/default.stm
// @exclude http://news.bbc.co.uk/2/hi/*/default.stm
// @exclude http://news.bbc.co.uk/sport1/hi/*/default.stm


// ==/UserScript==

function RunScript() {
relax(window.document,document.evaluate('/HTML[1]/BODY[1]/TABLE[1]/TBODY[1]/TR[1]/TD[1]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,null,null,null);
relax(window.document,document.evaluate('/HTML[1]/BODY[1]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,null,null,null);
}; // Ends do_platypus_script
window.addEventListener("load", function() { RunScript() }, false);

function relax(doc, node) {
  walk_down(node, function (node) {
      node.style.width = 'auto';
      node.style.marginLeft = '0pt';
      node.style.marginRight = '0pt';
      if (node.width) node.width = null; });
}

function walk_down(node, func) {
  if (node.nodeType == 1) {
    if (node.tagName != "IMG") func(node);
    if (node.childNodes.length != 0)
      for (var i=0; i<node.childNodes.length; i++)
walk_down(node.childNodes.item(i),func);
  }
}

//.user.js