points by gwu78 12 years ago

Everytime I have to read one of these "blogspot" blogs, I find myself rewriting my "one-off" solution again so I can read the blogger blog posts without Javascript.

For the 1 or 2 people out there reading who like to use a text-based browser and find gratuitous Javascript annoying, I have pasted this solution for you below.

Note: Some blogspot blogs do not have feeds enabled and will give a 404. Some of these appear not to require Javascript; in that case, this script becomes unneccessary.

  # fetch a blogger.com blog ...
  # without the gratuitous javascript
  # usage: 
  # nameofthisfile nameofblog > htmlfile
  # yourfavoritebrowser htmlfile

  # requirements:
  # netcat
  # openssl
  # sed
  # optional: strings
  # optional: addcr

  type strings 2>&1 >&- ||
  strings(){ sed ;}
  type addcr 2>&1 >&- ||
  addcr(){ sed ;}

  case $1 in
  0) # get HTML
  case $# in
  2)
  shift
  {
  printf "GET / HTTP/1.0\r\n"; 
  printf "Host: $1.blogspot.com\r\n";
  printf "Connection: Close\r\n";
  printf "\r\n";
  } \
  |nc -vv www.blogger.com 80
  ;;
  *)
  echo usage: $0 $1 nameofblog
  esac
  ;;
  1) # filter for BlogID
  sed '
  s/\\046/\&/g;
  s/\\46/\&/g;
  s/\\075/=/g;
  s/\\75/=/g;
  /targetBlogID/!d;
  s/.*targetBlogID=//;
  s/&.*//;
  ' |sed 1q
  ;;
  2) # convert BlogID to HTTP
  while read a
  do
  {
  printf "%b" "GET /feeds/$a/posts/default HTTP/1.1\r\n"; 
  printf "Host: www.blogger.com\r\n";
  printf "Connection: Close\r\n";
  printf "\r\n";
  } 
  done
  ;;
  3) # s_client www.blogger.com  
  openssl s_client -ign_eof -connect \
  www.blogger.com:443 -verify 9 \
  |addcr
  ;;
  4) # filter for reading
  {
  echo
  sed '
  s/&lt;/</g;
  s/&gt;/>/g;
  s/&amp;/\&/g;
  s/&quot;/\"/g;
  1i\
  <br><br>

  s/<name>/<br><br>name &/g;
  s/<uri>/<br>uri &/g;
  s/<generator>/<br>generator &/g;
  s/Blogger//;
  s/<id>/<br>id &/g;
  s/<published>/<br>published &/g;
  s/<email>/<br>email &/g;
  s/<title type=.text.>/<br><br>&/g;
  s/<openSearch:totalResults>/<br>total results &/g;
  s/<openSearch:startIndex>/<br>start index &/g;
  s/<openSearch:itemsPerPage>/<br>items per page &/g;
  s/<updated>/<br>updated &/g;
  s/<thr:total>/<br>thr:total &/g;
  s/<\/feed>/&<br><br><br>/;

  s/^M*/<br>/;
  '  \
  |strings
  }
  ;;
  5) # all of the above
  case $# in
  2)
  shift
  $0 0 $1 \
  |$0 1 \
  |$0 2 \
  |$0 3 \
  |$0 4
  ;;
  *) 
  echo usage $0 $1 nameofblog
  esac
  ;;
  *)
  a=$(type $0|sed 's/.* //')
  sed '/[)] *#/!d' $a
  esac
mkartic 12 years ago

thanks! Will check it out. I use noscript, which is a slightly easier option in this case than a text based browser. :) But having a very strict whitelisting policy, I have to allow 3-4 sites to run JS temporarily everytime I decide to read something on blogger.