יוצר: אני (את הרוב לפחות).
גירסא: v1.3.
תיאור: הקוד מאפשר יצירת קיצור דרך לכתובת מסוימת דרך האתר TinyURL בנוסף יש אפשרות לבדוק לאן קישור מהאתר מוביל.
הפעלה: דיאלוג.
תמונה:
קוד: בחר הכל
menu * {
TinyURL v1.3 [/TinyURL] { TinyURL }
}
alias TinyURL {
if (!$dialog(TinyURL)) dialog -m TinyURL TinyURL
}
dialog TinyUrl {
title "TinyURL v1.3 [/TinyURL]"
size -1 -1 144 85
option dbu
tab "Link Generator", 5, 6 4 131 63
button "Generate", 3, 11 33 51 17, tab 5
text "Enter URL here:", 1, 11 22 41 8, tab 5
edit "", 2, 54 21 80 10, tab 5
edit "", 4, 11 54 122 10, tab 5 read autohs
text "TinyUrl short link:", 6, 66 41 63 8, tab 5
tab "Link Checker", 7
edit "", 8, 54 21 80 10, tab 7
text "Enter URL here:", 9, 11 22 40 8, tab 7
button "Check", 10, 11 33 51 17, tab 7
text "Original link:", 11, 66 41 63 8, tab 7
edit "", 12, 11 54 122 10, tab 7 read autohs
button "Settings", 13, 6 71 31 10
text "TinyURL v1.3 created by ShaharZ", 14, 40 73 97 8
}
on *:Dialog:TinyUrl:sclick:*: {
if ($did == 3) {
tinyurlv $did(2)
if (%TinyURL.autocopy == OFF) { set %TinyURL.copy $?!="Would you like to copy the link to clipboard" }
}
if ($did == 10) {
tinyurlcheck $did(8)
if (%TinyURL.autocopy == OFF) { set %TinyURL.copy $?!="Would you like to copy the link to clipboard" }
}
if ($did == 13) {
TinyURLs
}
}
alias TinyURLs {
if (!$dialog(TinyURLs)) dialog -m TinyURLs TinyURLs
}
dialog TinyURLs {
title "TinyURL v1.3 Settings [/TinyURLs]"
size -1 -1 144 29
option dbu
check "Auto copy links after check/generate", 1, 6 5 122 10
edit "", 2, 5 16 133 10, read
}
on *:Dialog:TinyURLs:sclick:*: {
if ($did == 1) { Set %TinyURL.autocopy $iif(%TinyURL.autocopy !== ON,ON,OFF) | did -ra TinyURLs 2 Auto Copy: %TinyURL.autocopy }
}
on *:dialog:TinyURLs:init:*: {
if (%TinyURL.autocopy == ON) { did -c $dname 1 }
}
alias tinyurlv {
var %c $iif($isid,return,echo -a)
if ($1) && (!$com(u)) && (!$sock(tinyurl)) {
if ($regex($1,/^(?:(?:f|ht)tps?:\/\/|[^<>\/:\s])+[^<>.:\/\s]+(?:\.[^\/:<>.\s]{2,6})+(?:\/.*?)?$/i)) {
sockopen tinyurl www.tinyurl.com 80
sockmark tinyurl /create.php?url= $+ $remove($1-,$chr(32))
.comopen u Wscript.Shell
.comclose u $com(u,run,1,bstr*,$(%comspec%,) /c ping.exe -n 2 127.0.0.1 >nul,uint,0,bool,true)
}
else did -ra TinyURL 4 Invalid URL!
}
else did -ra TinyURL 4 $iif($1,Please be patient...,Input a URL!)
}
on *:sockopen:tinyurl: {
if ($sockerr) {
did -ra TinyURL 4 Error connecting: $sock($sockname).wsmsg
sockclose $sockname
}
else {
sockwrite -n $sockname GET $sock($sockname).mark HTTP/1.1
sockwrite -n $sockname Host: tinyurl.com
sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8)
sockwrite -n $sockname $crlf
}
}
on *:sockread:tinyurl: {
if ($sockerr) {
did -ra TinyURL 4 Error connecting: $sock($sockname).wsmsg
sockclose $sockname
}
else {
var %x
sockread %x
if ($regex(%x,/<blockquote><b>(.*?)<\/b><br>/)) {
did -ra TinyURL 4 $regml(1)
if (%TinyURL.autocopy == ON) { /clipboard $regml(1) }
else { .timer 1 1 copy $regml(1) }
sockclose $sockname
}
}
}
alias tinyurlcheck {
if ($1) {
if ($regex($1,/^(?:(?:f|ht)tps?:\/\/|[^<>\/:\s])+[^<>.:\/\s]+(?:\.[^\/:<>.\s]{2,6})+(?:\/.*?)?$/i)) {
if (tinyurl.com isin $1) {
sockopen tinyurl_check tinyurl.com 80
sockmark tinyurl_check $remove($1,http://,tinyurl.com/)
}
else did -ra TinyURL 12 Invaild URL! only except links from tinyurl.com
}
else did -ra TinyURL 12 Invalid URL!
}
else did -ra TinyURL 12 $iif($1,Please be patient...,Input a URL!)
}
on *:sockopen:tinyurl_check:{
.timertinyurlcheck 1 20 did -ra TinyURL 12 There appears to be no redirect for http://tinyurl.com/ $+ $sock($sockname).mark
sockwrite -n $sockname GET /preview.php?num= $+ $sock($sockname).mark HTTP/1.0
sockwrite -n $sockname Host: tinyurl.com
sockwrite -n $sockname $crlf
}
on *:sockread:tinyurl_check:{
var %x
sockread -f %x
if (<blockquote><b> isin %x) {
.timertinyurlcheck off
did -ra TinyURL 12 $remove(%x, <blockquote><b>,<br /></b></blockquote>)
if (%TinyURL.autocopy == ON) { /clipboard $remove(%x, <blockquote><b>,<br /></b></blockquote>) }
else { .timer 1 1 copy $remove(%x, <blockquote><b>,<br /></b></blockquote>) }
sockclose $sockname
}
}
alias copy {
if (%TinyURL.copy) { /clipboard $1 }
.timer 1 2 unset %TinyURL.copy
}