Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Google Script by Ford_Lawnmower irc.mindforge.org #USA
- dialog Google_Search {
- title "Google Search"
- size -1 -1 184 248
- option dbu
- edit "", 1, 8 14 130 10, autohs
- button "Search", 2, 139 14 37 12
- text "Enter your Search Below", 3, 56 6 73 8
- text "Results:", 4, 82 24 25 8, center
- text "", 5, 1 32 183 24, left
- text "", 6, 1 72 183 24, left
- text "", 7, 1 112 183 24, left
- text "", 8, 1 152 183 24, left
- text "", 9, 1 192 183 24, left
- link "", 10, 1 56 182 16
- link "", 11, 1 96 182 16
- link "", 12, 1 136 182 16
- link "", 13, 1 176 182 16
- link "", 14, 1 216 182 16
- button "Close", 15, 144 235 37 12, Cancel
- text "", 16, 0 232 137 16
- box "", 17, 0 28 184 44
- box "", 18, 0 68 184 44
- box "", 19, 0 108 184 44
- box "", 20, 0 148 184 44
- box "", 21, 0 188 184 44
- icon 22, 0 2 47 11
- }
- On *:Dialog:Google_Search:init:*: {
- if (!$isfile(logo_sm.gif)) { getlogo | .timer 1 2 did -g Google_Search 22 logo_sm.gif }
- else { did -g Google_Search 22 logo_sm.gif }
- google hawkee mirc scripts
- }
- On *:Dialog:Google_Search:Close:*: {
- unset GoogleDialog.*
- if ($sock(GoogleDialog)) { sockclose GoogleDialog }
- }
- On *:Dialog:Google_Search:Sclick:2: {
- if ($did(Google_Search,1).text) {
- var %count = 5
- while (%count <= 14) {
- did -r Google_Search %count
- inc %count
- }
- did -r Google_Search 16
- Google $did(Google_Search,1).text
- }
- else { return }
- }
- On *:Dialog:Google_Search:Sclick:10-14: {
- if ($did(Google_Search,$did).text) {
- if (http:// isin $left($did(Google_Search,$did).text,7)) {
- if ($input(Are you sure you want to load $did(Google_Search,$did).text $+ ?,y,,,)) { run $did(Google_Search,$did).text }
- else { return }
- }
- else {
- did -r Google_Search 16
- Google $did(Google_Search,$did).text
- }
- }
- else { return }
- }
- alias -l Google.timeout {
- echo -at >Connection Timed Out< Google Script
- Google.clear
- }
- alias -l Google.clear {
- sockclose Google*
- unset %Google*
- .timer-Google* off
- halt
- }
- alias -l Google {
- set $+(%,Google,dialog,.count) 1
- sockclose $+(Google,dialog)
- set $+(%,Google,dialog,.search) $replace($1-,$chr(32),+)
- sockopen $+(Google,dialog) www.google.com 80
- .timer $+ $+(Google,dialog) 1 10 Google.Clear
- }
- #GoogleTrigger on
- on *:TEXT:!Google*:# {
- if ($sock($+(Google,$chan))) { .notice $nick Google in use!! | halt }
- if (!$2) { .notice $nick Please provide something for me to search for!! Syntax is !Google search words here | halt }
- set $+(%,Google,$chan,.nick) $nick
- set $+(%,Google,$chan,.chan) $chan
- set $+(%,Google,$chan,.count) 1
- set $+(%,Google,$chan,.search) $replace($2-,$chr(32),+)
- sockclose $+(Google,$chan)
- sockopen $+(Google,$chan) www.google.com 80
- .timer $+ $+(Google,$chan) 1 10 Google.Clear
- }
- #GoogleTrigger End
- on *:sockopen:Google*: {
- var %search = $eval($+(%,$sockname,.search),2)
- sockwrite -n $sockname GET $+(/search?client=opera&rls=en&q=,%search,&sourceid=opera&ie=utf-8&oe=utf-8) HTTP/1.1
- sockwrite -n $sockname Host: www.google.com $+ $CRLF $+ $CRLF
- }
- on *:sockread:Google*: {
- if ($sockerr > 0) { echo -a >Sock Error< Google | Google.clear }
- else {
- sockread &Google
- if ($bintween(&Google,class=p><b><i>,</i></b>,1)) {
- if ($sockname == Googledialog) {
- did -a Google_Search 16 $strip($eval($+(%,$sockname,.chan),2) $fixhtml($+(Did You Mean,$chr(32),$bintween(&Google,class=p><b><i>,</i></b>,1),?)))
- }
- else { .msg $eval($+(%,$sockname,.chan),2) $fixhtml($+(Did You Mean,$chr(32),$bintween(&Google,class=p><b><i>,</i></b>,1),?)) }
- }
- if ($bintween(&Google,<p>Your search,did not match any documents.,1)) {
- if ($sockname == Googledialog) { did -a Google_Search 5 Your Search Did not Match any Documents }
- else { .msg $eval($+(%,$sockname,.chan),2) $fixhtml(Zero Results found for your Search) }
- Google.Cleanup $sockname
- }
- if ($bintween(&Google,class=l>,<cite>,1)) && ($bintween(&Google,=r><a href="http://," class=l>,1)) && (results for <em> !isin $bintween(&Google,=r><a href=,s=l>,2)) {
- if (results for <em> !isin $bintween(&Google,=r><a href=,s=l>,1)) {
- if ($sockname == Googledialog) {
- did -a Google_Search $calc($+(%,$sockname,.count) + 4) $dfix($eval($+(%,$sockname,.chan),2) $fixhtml($bintween(&Google,class=l>,<cite>,1)))
- did -a Google_Search $calc($+(%,$sockname,.count) + 9) $httpstrip($+(http://,$bintween(&Google,=r><a href="http://," class=l>,1)))
- }
- else { .msg $eval($+(%,$sockname,.chan),2) $fixhtml($bintween(&Google,class=l>,<cite>,1) $+(http://,$bintween(&Google,=r><a href="http://," class=l>,1))) }
- inc $+(%,$sockname,.count)
- }
- if ($eval($+(%,$sockname,.count),2) >= 6) { Google.Cleanup $sockname }
- if ($httpstrip($bintween(&Google,class=l>,</cite>,2))) && ($httpstrip($bintween(&Google,=r><a href="http://," class=l>,2))) {
- if ($sockname == Googledialog) {
- did -a Google_Search $calc($+(%,$sockname,.count) + 4) $dfix($eval($+(%,$sockname,.chan),2) $fixhtml($bintween(&Google,class=l>,<cite>,2)))
- did -a Google_Search $calc($+(%,$sockname,.count) + 9) $httpstrip($+(http://,$bintween(&Google,=r><a href="http://," class=l>,2)))
- }
- else { .msg $eval($+(%,$sockname,.chan),2) $fixhtml($bintween(&Google,class=l>,<cite>,2) $+(http://,$bintween(&Google,=r><a href="http://," class=l>,2))) }
- inc $+(%,$sockname,.count)
- }
- if ($eval($+(%,$sockname,.count),2) >= 6) { Google.Cleanup $sockname }
- if ($httpstrip($bintween(&Google,class=l>,</cite>,3))) && ($httpstrip($bintween(&Google,=r><a href="http://," class=l>,3))) {
- if ($sockname == Googledialog) {
- did -a Google_Search $calc($+(%,$sockname,.count) + 4) $dfix($eval($+(%,$sockname,.chan),2) $fixhtml($bintween(&Google,class=l>,<cite>,3)))
- did -a Google_Search $calc($+(%,$sockname,.count) + 9) $httpstrip($+(http://,$bintween(&Google,=r><a href="http://," class=l>,3)))
- }
- else { .msg $eval($+(%,$sockname,.chan),2) $fixhtml($bintween(&Google,class=l>,<cite>,3) $+(http://,$bintween(&Google,=r><a href="http://," class=l>,3))) }
- inc $+(%,$sockname,.count)
- }
- if ($eval($+(%,$sockname,.count),2) >= 6) { Google.Cleanup $sockname }
- }
- }
- }
- menu * {
- Google
- .Dialogs:Google_Search
- .$iif($group(#GoogleTrigger) == On,$style(1)) GoogleTrigger
- ..$iif($group(#GoogleTrigger) == On,$style(2)) On: .enable #GoogleTrigger
- ..$iif($group(#GoogleTrigger) == Off,$style(2)) Off: .disable #GoogleTrigger
- }
- alias -l Google.Cleanup {
- unset $+(%,$1,.*)
- .timer $+ $1 off
- sockclose $1
- halt
- }
- alias -l Google_Search {
- if ($dialog(Google_Search)) { dialog -v Google_Search Google_Search }
- else { dialog -m Google_Search Google_Search }
- }
- alias -l dfix {
- return $left($remove($strip($1-),**google**),200)
- }
- alias -l fixhtml {
- var %fixmatch = $regex($1-,/(&#.*?;)/g), %fixtext = $replace($1-,<div class="s">,$chr(32))
- while (%fixmatch) {
- %fixtext = $replace(%fixtext,$regml(%fixmatch),$chr($remove($regml(%fixmatch),&#,;)))
- dec %fixmatch
- }
- return 12**04G07o06o09g08l13e12** $httpstrip($replace($remove(%fixtext,>,<,&,",·,$chr(124)),$CRLF,$chr(32)))
- }
- alias -l bintween {
- var %count = 1, %mark = 0, %mark2 = 0
- while (%count <= $4) {
- if ($bfind($1, %mark2, $2).text) {
- %mark = $calc($bfind($1, %mark2, $2).text + $len($2))
- if ($bfind($1, %mark, $3).text) {
- %mark2 = $bfind($1, %mark, $3).text
- }
- else { return 0 }
- }
- else { return 0 }
- inc %count
- }
- if ($calc(%mark2 - %mark) > 960) && ($version < 6.32) { return 0 }
- else { return $bvar($1, $iif(%mark > 0,%mark,1), $calc(%mark2 - %mark)).text }
- }
- alias -l httpstrip {
- var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
- return %x
- }
- Alias -l GetLogo {
- if ($isfile(logo_sm.gif)) { return }
- set %GetLogo.Site www.google.com
- set %GetLogo.URL /images/logo_sm.gif
- set %GetLogo.PicName logo_sm.gif
- sockclose GetLogo
- sockopen GetLogo %GetLogo.site 80
- }
- On *:sockopen:GetLogo:{
- sockwrite -nt $sockname GET %GetLogo.url HTTP/1.0
- sockwrite $sockname Host: %GetLogo.site $+ $crlf $+ $crlf
- }
- On *:sockread:GetLogo:{
- if (!$sock($sockname).mark) {
- var %GetLogo.var | sockread %GetLogo.var
- if (%GetLogo.var == $null) { sockmark $sockname 1 }
- }
- else {
- sockread &logo
- bwrite logo_sm.gif -1 -1 &logo
- }
- }
- On *:sockclose:GetLogo:{
- unset %GetLogo.*
- }
Add Comment
Please, Sign In to add comment