tglogo.png

Downloading File

Filename: Google Definer
;;;; Zmodem
;www.google.com
;GET /search?hl=en&safe=off&q=define%3A<WORD1>+<WORD2>+<ETC> HTTP/1.0

alias -l atext did -a gdef 1 $1-
alias -l htmlfree { return $regsubex($$1-,/^[^<]*>|<[^>]*>|<[^>]*$/g,) }
alias gdef if ($1 != $null) { dialog $iif(!$dialog(gdef),-m,-a) gdef gdef | set %googledef $replace($1-,$chr(32),+) | sockclose GoogleDef | sockopen GoogleDef www.google.com 80 }
alias -l between { 
  noop $regex($1,/\Q $+ $2 $+ \E(.*?)\Q $+ $3 $+ \E/gi) 
  return $regml($4) 
}
ON *:SOCKOPEN:GoogleDef: { did -r gdef 1 | atext (Definition of: %googledef $+ ) $+ $crlf | sockwrite -n GoogleDef GET /search?hl=en&safe=off&q=define%3A $+ %googledef HTTP/1.0 | sockwrite -n GoogleDef Host: www.google.com $+ $crlf $+ $crlf }
ON *:SOCKCLOSE:GoogleDef: {
  if ($dialog(gdef)) {
    atext $crlf $+ $crlf $+ $iif(!$did(gdef,1,2),No Definition Found...,Finished!) 
    did -c gdef 1 1 
    unset %googledef
  }
}
ON *:SOCKREAD:GoogleDef:{
  if ($sockerr > 0) { atext No Definition Found $+ $crlf $+ $crlf (ERROR: $sock(GoogleDef).wserr $+ ) | return }
  var %iData
  :gather
  sockread %iData
  if ($sockbr == 0) return
  if (!%iData) %iData = $chr(160)
  var %i = 1, %m = $between(%iData,<li>,<li>,0), %i2 = 1, %m2 = $between(%iData,<li>,<br>,0)
  while (%i <= %m) {
    atext $dorep($htmlfree($between(%iData,<li>,<li>,%i)))
    inc %i
  }
  while (%i2 <= %m2) {
    atext $dorep($htmlfree($between(%iData,<li>,<br>,%i2)))
    inc %i2
  }
  goto gather
}
alias -l dorep return $replace($1-,.html,.html $+ $crlf $+ $crlf,*,$crlf,&quot;,",...,$crlf $+ $crlf)

dialog -l gdef {
  title "GoogleDef"
  size -1 -1 267 200
  option dbu
  edit "", 1, 4 4 259 174, vsbar multi return read
  button "&Close", 2, 83 182 36 15, cancel
  button "&Save As...", 3, 136 182 36 15
}
ON *:DIALOG:gdef:close:0:sockclose gdef | unset %googledef
ON *:DIALOG:gdef:sclick:3: {
  var %f = $qt($sfile($qt($mircdir),Save to:,&Save)), %i = 1, %m = $did(1).lines, %t
  if (%f) {
    if ($isfile(%f)) {
      if ($input(This file already exists. Do you wish to overwrite it?,yn,File Exists)) { write -c %f }
      else { return }
    }
    while (%i <= %m) {
      %t = $did(1,%i)
      write %f $iif(%t,%t,$crlf)
      inc %i
    }
    return $input(Successfully saved to: %t,iok6,Save Complete)
  }
}

Related Files

by mountaindew
by Soul_Eater

Please note that on our website we use cookies necessary for the functioning of our website, cookies that optimize the performance. To learn more about our cookies, how we use them and their benefits, please read our Cookie Policy.
I Understand