my first greasemonkey script

Time to time I order translations of xml.com articles. It's not cheap, and I try to reduce costs. One of the most obvious approaches is to ignore code listings when calculating the price. Till recently, I did it as follows.

1) I dropped ads from the HTML text of the article,
2) opened HTML in firefox,
3) copied the text to OpenOffice,
4) manually deleted code listings,
5) checked document statistics (number of characters and words).

The step "4" is very boring. I hated it. I hated it so much that I've found time to look at my "Greasemonkey Hacks" book, learnt a bits of Greasemonkey and written a script to delete code from the text. Now the process looks as the following:

1) I drop ads from the HTML text of the article,
2) open HTML in firefox
2b) (the script deletes code),
3) copy the text to OpenOffice,
4) check document statistics (number of characters and words).

Life is much easier now. And here is the script:

// ==UserScript==
// @name            Drop code
// @namespace       http://uucode.com/
// @description     Drop code listings in "code" tags
// @include         file:///home/olpa/p/RAC/to_rus/*
// ==/UserScript==

if (confirm ("Drop code?")) {
  drop_code();
}

function drop_code() {
  var i, elems;
  elems = document.getElementsByTagName('code');
  for (i in elems) {
    elems[i].innerHTML = '';
  }
}

Categories:

Updated: