Skip to content

Instantly share code, notes, and snippets.

@rornor rornor/gspls.hta Secret
Last active Dec 13, 2015

Embed
What would you like to do?
GrooveShark Playlist Player
<html>
<head>
<title>GrooveShark Playlist Player</title>
<HTA:APPLICATION
APPLICATIONNAME="GrooveShark Playlist Player"
ID="GSpls"
VERSION="0.1"
BORDER="none"
INNERBORDER="no"
SELECTION="no"
CONTEXTMENU="yes"
SINGLEINSTANCE="yes"
NAVIGABLE="yes"
ICON="http://grooveshark.com/webincludes/images/favicon64.ico" />
<script language="VBScript">
<!--
width = 340
height = 600
ResizeTo width, height
MoveTo (screen.AvailWidth-width)/2, (screen.AvailHeight-height)/2
x = 0 : y = 0 : m = 0
Function setpos()
move_me.style.color = "#000000"
move_me.style.backgroundColor = "#6AAEF5"
main.style.backgroundColor = "#6AAEF5"
close_button.style.backgroundColor = "#5B92D2"
main.style.borderColor = "#5B92D2"
window.event.srcElement.hideFocus = 1
x = window.event.screenX
y = window.event.screenY
m = 1
End Function
Function domove()
If m = 1 Then
moveX = 0 : moveY = 0
moveX = window.event.screenX - x
moveY = window.event.screenY - y
window.moveto(window.screenLeft + moveX), (window.screenTop + moveY)
setPos()
End if
End Function
Function stopmove()
move_me.style.color = "#444444"
move_me.style.backgroundColor = "#EBEBEB"
main.style.backgroundColor = "#EBEBEB"
close_button.style.backgroundColor = "#BABABA"
main.style.borderColor = "#C9C9C9"
m = 0
End Function
//-->
</script>
<style type="text/css">
body,form,input,object,div {
margin: 0;
border: 0;
padding: 0;
font-family: "Segoe UI","Trebuchet MS",Arial;
}
body {
padding: 28px 6px 6px 6px;
border: 1px solid #C9C9C9;
overflow: hidden;
}
form {
background-color: #FFFFFF;
padding: 0 0 10px 0;
}
#input_box {
color: silver;
font-size: 9pt;
width: 300px;
height: 26px;
padding: 0px 28px 0px 4px;
border: solid 1px #C9C9C9;
line-height: 24px;
}
#move_me,#close_button,#go_button {
position: absolute;
top: 0;
}
#move_me {
background-color: #EBEBEB;
color: #444444;
font-size: 11pt;
right: 50px;
width: 250px;
height: 28px;
cursor: move;
}
#close_button {
background-color: #BABABA;
color: white;
font-family: Verdana,Tahoma;
font-size: 10pt;
right: 6px;
width: 45px;
height: 20px;
text-align: center;
}
#go_button {
display: none;
background-color: white;
color: silver;
font-family: Verdana,Tahoma;
font-size: 10.5pt;
top: 43px;
right: 20px;
width: 24px;
height: 24px;
text-align: center;
}
table {
background-color: #FFFFFF;
border-collapse: collapse;
border: 1px solid #D7D7D7;
}
td {
text-align: center;
padding-top: 12px;
padding-bottom: 12px;
}
td#groove {
background: url('http://dl.dropbox.com/u/30782742/img/EFC380E1.png') no-repeat center;
padding: 0px auto;
height: 435px;
}
#dd, #ax {
width: 300px;
height: 41px;
background-color: #E9E9E9;
font-size: 9pt;
color: #707070;
text-align: center;
line-height: 36px;
cursor: pointer;
}
#dd {
position: absolute;
top: 538px;
left: 19px;
border: 1px solid #D7D7D7;
}
#dt {
height:65px;
}
</style>
</head>
<script language="VBScript">
<!--
Dim msg, gs
api_key = "b07b690c6c2a7f32402dc2d34c5a2a65"
arg = Split(gspls.commandLine, Chr(34))
If Ubound(arg) > 3 Then msg = arg(3)
url = "http://tinysong.com/b/" : par = "?key=" & api_key
msgs = "Enter playlist path. Playlist too big; Query aborted. Invalid path. Empty file. Playlist not valid." &_
"No result. Not supported filetype. Registering aborted. Operation successful; Changes available on restart."
msg = Split(msgs, ".")(0)
Sub window_onload()
move_me.style.backgroundColor = document.bgcolor
groove.innerHtml = gs
search.input_box.value = msg
tab.focus
End Sub
Sub ax_Click()
fopen()
End Sub
Sub ax_OLEDragDrop(Data, Effect, Button, Shift, x, y)
If Data.GetFormat(15) Then
If InStr("txt,m3u,xml,spf", Right(Data.Files.Item(1), 3)) Then
ax.Backcolor = &H53A615&
search.input_box.value = Data.Files.item(1) : go()
Else
msg = "Not supported filetype"
window_onload()
End If
End If
End Sub
Sub ax_OLEDragOver(Data, Effect, Button, Shift, x, y, State)
If State = 0 Then
If InStr("txt,m3u,xml,spf", Right(Data.Files.item(1), 3)) Then ax.Backcolor = &H4217B5&
End If
If State = 1 Then ax.Backcolor = &H53A615&
End Sub
Sub RegisterDragDrop(h)
sKey = "HKEY_CLASSES_ROOT\HTAFile\ShellEx\DropHandler\" : sValue = "{60254CA5-953B-11CF-8C96-00AA00B8708C}"
dKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\{B09DE715-87C1-11D1-8BE3-0000F8754DA1}\Compatibility Flags"
With CreateObject("WScript.Shell")
On Error Resume Next
d = .regread(dKey)
If Err.Number Then
msg = "Registering aborted"
Else
.regread(sKey)
If Err.Number Then .regwrite sKey, sValue, "REG_SZ"
If h <> d Then .regwrite dKey, CStr(h), "REG_DWORD"
If h = .regread(dKey) Then msg = "Operation successful; Changes available on restart"
End If
On Error Goto 0
window_onload()
End With
End Sub
Function Request(url)
Set HTTP = CreateObject("MSXML2.XMLHTTP")
On Error Resume Next
HTTP.open "GET", url, False
HTTP.send ""
If Not Err.number Then resp = HTTP.responseText
On Error GoTo 0
Request = resp
End Function
Function Parse(path)
If Not CBool(InStr(path, ".")) Or Left(path, 1) = "?" Then
Parse = path
ElseIf InStr("txt,m3u,xml,spf", Right(path, 3)) Then
If Left(path, 7) = "http://" Then
pls = Request(path)
Else
With CreateObject("Scripting.FileSystemObject")
If .FileExists(path) Then
pls = .OpenTextFile(path).ReadAll
Else
Parse = "Invalid path"
End If
End With
End If
If Len(pls) > 10000 Then
Parse = "Playlist too big; Query aborted"
ElseIf Len(pls) Then
If Right(path, 4) = ".txt" Then
Parse = Replace(pls, vbCrLf, ";")
ElseIf Right(path, 4) = ".m3u" Then
For Each line in Filter(Split(pls, vbCrLf), "#EXTINF")
tracks = tracks & Split(line, ",")(1) & ";"
Next
Parse = tracks
ElseIf Right(path, 4) = ".xml" Or Right(path, 5) = ".xspf" Then
With CreateObject("MSXML2.DOMDocument.6.0")
.loadXML(pls)
.async = False
.setProperty "SelectionNamespaces", "xmlns:x='http://xspf.org/ns/0/'"
For Each node in .selectSingleNode("x:playlist").childnodes
If node.nodeName = "trackList" Then
For Each track In node.childNodes
For Each tag In track.childNodes
If InStr("title.creator", tag.nodeName) Then tracks = tracks & " " & tag.text
Next
tracks = tracks & ";"
Next
End If
Next
Parse = tracks
End With
End If
Else
Parse = "Empty file"
End If
Else
Parse = "Invalid path"
End If
End Function
Function ParseResponse(sid)
If InStr(sid, "rate limit exceeded") Or InStr(sid, "api key missing") Then
If MsgBox("Rate limit exceeded." & vbCrLf & vbCrLf & "Press OK to get new api key from 'http://tinysong.com/api' and set it on line 156" & vbCrLf, 49, "Error") = vbOK Then CreateObject("WScript.Shell").Run("http://tinysong.com/api")
window.close
ElseIf InStr(sid, """error""") Then
MsgBox "Error occured." & vbCrLf & vbCrLf & "Message is: " & sid & vbCrLf, 48, "Error"
window.close
ElseIf sid <> "NSF;" Then
ParseResponse = 1
End If
End Function
Sub Go()
msg = search.input_box.value
search.go_button.style.color = "silver"
search.go_button.style.display = "none"
If Len(msg) And msg <> "Enter playlist path" Then
shade() : gs = ""
tracks = Parse(msg)
If Len(tracks) Then
On Error Resume Next
If tracks = msg Then
sid = Request(Replace(url, "/b/", "/s/") & Replace(Trim(Replace(tracks,"?", "")), " ", "+") & par & "&limit=32")
If ParseResponse(sid) Then
For Each track in Split(sid, "http://")
If Split(track, "; ")(1) Then ids = ids & Split(track, "; ")(1) & ","
Next
End If
If Not CBool(Len(ids)) Then msg = "No result"
ElseIf Not CBool(InStr(tracks, ";")) Then
msg = tracks
Else
For Each track in Split(tracks, ";")
sid = Request(url & Replace(Trim(Replace(track, vbTab, " ")), " ", "+") & par)
If ParseResponse(sid) Then
If Split(sid, "; ")(1) Then ids = ids & Split(sid, "; ")(1) & ","
End If
Next
If Not CBool(Len(ids)) Then msg = "No result"
End If
On Error GoTo 0
If Len(ids) Then
scheme = "&bbg=1177CB&pbg=1177CB&pfg=FFFFFF&pbgh=6AAEF5&pfgh=FFFFFF&bt=6AAEF5&bth=FFFFFF&bfg=1177CB&lfg=EBEBEB&lbg=1177CB&lfgh=FFFFFF&lbgh=6AAEF5&sb=6AAEF5&sbh=FFFFFF&p=0"
gs = "<object width='300' height='400'>" & vbCrLf &_
" <param name='movie' value='http://grooveshark.com/widget.swf' />" & vbCrLf &_
" <param name='flashvars' value='hostname=cowbell.grooveshark.com&songIDs=" & Left(ids, Len(ids)-1) & scheme & "' />" & vbCrLf &_
" <embed src='http://grooveshark.com/widget.swf' " & vbCrLf &_
" type='application/x-shockwave-flash' width='300' height='400'" & vbCrLf &_
" flashvars='hostname=cowbell.grooveshark.com&songIDs=" & Left(ids, Len(ids)-1) & scheme & "'" & vbCrLf & "</object>"
End If
Else
msg = "Playlist not valid"
End If
window_onload()
End If
End Sub
Sub Clean()
For Each m in Filter(Split(msgs, "."), search.input_box.value)
search.input_box.value = ""
Next
search.input_box.style.color = "black"
search.input_box.style.fontSize = "11pt"
End Sub
Sub Shade()
If search.input_box.value = "" Then search.input_box.value = "Enter playlist path"
If Not document.activeElement.id = "go_button" Then search.go_button.style.display = "none"
search.input_box.style.color = "silver"
search.input_box.style.fontSize = "9pt"
End Sub
Sub fopen()
On Error Resume Next
Set sh = CreateObject("WScript.Shell")
If sh.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE") = "x86" Then
For Each obj In Split("UserAccounts.CommonDialog MSComDlg.CommonDialog MSComDlg.CommonDialog.1")
Set dlg = CreateObject(obj)
If IsObject(dlg) Then
If InStr(obj, "MSComDlg") Then dlg.MaxFileSize = 256
dlg.Filter = "EXTM3U Playlist|*.m3u|XSPF Playlist|*.xspf|TXT List|*.txt|All Files|*.*"
dlg.ShowOpen : msg = dlg.FileName
been_there = True
Exit For
End If
Next
End If
If Not been_there Then
msg = sh.Exec("mshta.exe ""about:<input name='Open' type='file' id='f'><script>f.click();new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(f.value);close();resizeTo(0,0);</script>""").StdOut.ReadLine
End If
On Error Goto 0
If Len(msg) Then window_onload() : search.input_box.focus
End Sub
Sub Document_onKeyDown()
If Window.Event.KeyCode = 9 Then search.go_button.style.display = "none"
If Window.Event.KeyCode = 13 Then go()
If Window.Event.KeyCode = 27 Then window.close
If Window.Event.KeyCode = 82 And window.event.ctrlKey Then RegisterDragDrop(0)
If Window.Event.KeyCode = 85 And window.event.ctrlKey Then RegisterDragDrop(&H400)
End Sub
//-->
</script>
<body bgcolor="#EBEBEB" id="main">
<input type="button" id="move_me" onmousedown="setpos" onmousemove="domove" onmouseup="stopmove" value="GrooveShark Playlist Player">
<input type="button" id="close_button" value="x" onclick="window.close" onmouseover="me.style.backgroundcolor='#C85051'" onmouseout="me.style.backgroundcolor='#BABABA'">
<table id="tab" width="100%">
<tr><td>
<form id="search">
<input type="text" id="input_box" onfocus="clean():search.go_button.style.display='block'" onblur="shade()">
<input type="button" id="go_button" value="&#182;" title="Submit" onclick="go()" onmouseover="me.style.color='black'" onmouseout="me.style.color='silver'">
</form>
</td></tr>
<tr><td id="groove"></td></tr>
<tr><td id="dt">
<object id="ax" classid="clsid:B09DE715-87C1-11D1-8BE3-0000F8754DA1"><param name="OleDropMode" value="1"><param name="BackColor" value="5482005"></object>
<div id="dd" title="Click to browse for playlist" onclick="fopen()" onmouseover="me.style.borderColor='#3598FE':me.style.color='#000000'" onmouseout="me.style.borderColor='#D7D7D7':me.style.color='#707070'">Open</div>
</td></tr>
</table>
</body>
</html>
@rornor

This comment has been minimized.

Copy link
Owner Author

commented Mar 4, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.