Project

General

Profile

[Script] HTA media viewer v0.9.2 » HTA media viewer v0.9.1.ini

Mr. BS, 02/05/2017 06:47 PM

 
; HTA media viewer
; http://dev.adiirc.com/boards/5/topics/533
; v0.9.1 by pereba

alias -l HTAversion {
return 0.9.1
}

on *:LOAD: {
set -u10 %HTAload 1
if ($version < 2.7) {
echo -agtc info AdiIRC version 2.7 or higher is required to use HTA Media Viewer. Unloading script...
unload -rs $script | .timerHTAupdate* off | unset %HTA_ENABLED
halt
}
if (!$exists($HTAconfig)) {
set %HTA_ENABLED 0
set -u4 %HTAunloading 1
enableToggle
halt
}
set -eu6 %HTAinstalling 1
set %HTA_ENABLED 1
freshConfig
}

alias HTAupdate {
sockclose HTA
sockopen HTA pastebin.com 80
sockmark $1
}
on *:sockopen:HTA:{
sockwrite -n HTA GET /raw/mDLb4baa HTTP/1.1
sockwrite -n HTA Host: $sock(HTA).addr $+ $str($crlf,2)
}
on *:sockread:HTA:{
var %HTAreader
sockread %HTAreader
if ($regex(%HTAreader,/htalastversion=(.*)/)) {
hadd HTAconfig LastUpdateCheck $ctime
if ($HTAversion < $$regml(1)) {
var %newversion = $regml(1)
if ($?!="HTA Media Viewer version %newversion is available. Do you want to upgrade now?") {
download -o HTAupgrade http://pastebin.com/raw/UXETCLbh $qt($scriptdir $+ HTA media viewer v $+ $regml(1) $+ .ini)
}
}
else {
if ($sock(HTA).mark != silent) noop $input(Good news! You already have the lastest version.,o,HTA Media Viewer Upgrade)
}
sockclose HTA
}
}

alias -l enableToggle {
if (!$exists($HTAconfig)) {
set %HTA_ENABLED 0

; Create HTA folder
var %dir $qt($adiircdirHTAmediaViewer)
if (!$exists(%dir)) mkdir %dir

; Download required files
HTAdown AdiIRC.ico 0B36riaEyLqg_c0tkV1p1MklhS2s
HTAdown openhand.cur 0B36riaEyLqg_NVg1RFltRkJZV28
HTAdown closedhand.cur 0B36riaEyLqg_NVlpbW1NWVZ5TXc
HTAdown HTAmediaViewer.hta 0B36riaEyLqg_ajlWUUo1TjV5Q0E
HTAdown HTAmediaViewer.htm 0B36riaEyLqg_VEJfUDByU3czQ3c

halt
}
freshConfig
set %HTA_ENABLED $iif(%HTA_ENABLED,0,1)
}

alias -l HTAdown {
var %url https://drive.google.com/uc?export=download&id= $+ $2 , %dir $qt($adiircdir $+ HTAmediaViewer\ $+ $1)
download -o HTAdown_ $+ $1 %url %dir
}

on *:DOWNLOAD:HTAupgrade: {
if ($downloaderr) {
echo -agtc info Failed to download files, try again later or get files manually in http://dev.adiirc.com/boards/5/topics/533
halt
}
else {
.remove $HTAconfig
.unload -rs $script
.remove $script
.load -rs $download($download).file
}
}

on *:DOWNLOAD:HTAdown_*: {
inc %HTAdown_count
if ($downloaderr) inc %HTAdown_error_count

; On finish attempt to download all files
if (%HTAdown_count == 5) {
; if one or more files failed, display error message
if (%HTAdown_error_count) {
noop $input(Failed to download all required files $+ $chr(44) $+ try to enable again for a new attempt or download all require files manually in website.,o,HTA Media Viewer Error)
}
else {
enableToggle
}
unset %HTAdown_*
}
}

on *:UNLOAD: {
.timerHTAupdate off
unset %HTA_ENABLED
set -u3 %HTAunloading 1
if ($hget(HTAconfig)) hfree $v1
}

on *:START: {
; Continue only if on LOAD event not triggered
if (%HTAinstalling || %HTAload) {
halt
}

; check for update after 10 minutes
.timerHTAupdate 1 600 if ( $!gettok( $duration( $calc( $ctime - $iif($hget(HTAconfig,LastUpdateCheck),$v1,$ctime) ) ,3) ,1,58) >= 24) HTAupdate silent

set -u4 %HTAstarting 1

if ($exists($HTAconfig)) {
freshConfig
}
; Missing HTA files? then lets disable script, when user enable it in menu, enableToggle alias will prompt.
else {
set %HTA_ENABLED 0
}
}

on *:OPTIONS: {
if ($uptime(AdiIRC,3) < 10) return
; Workaround in case user paste script content instead to load a file (initialization warning shows only on closing editor in this case)
if (%HTAunloading || %HTAstarting || %HTAload) return

if ($exists($HTAconfig)) freshConfig AdiColors
}

alias -l freshConfig {
var %n HTAconfig, %f $HTAconfigFile, %e $exists(%f)

if ($1 == AdiColors && %e) {
goto $1
}

; If config not exists lets create one based on default values
if (%e == $false) {
if (!$hget(HTAconfig)) hmake %n
hadd %n SIZE_LIMIT_ENABLED 0
hadd %n MAX_WIDTH 300
hadd %n MAX_HEIGHT 300
hadd %n BORDER none
hadd %n CLOSE_ONBLUR 0
hadd %n WEBM_PLAYER $envvar(programfiles) $+ \Windows Media Player\wmplayer.exe
hadd %n SERVICES_ENABLED Coub,Dropbox,Gfycat,Pasteboard,Porngifs,Prntscr/Lightshot,Uploadpie,Vimeo,Youtube,Pastebin
hadd %n USE_DEFAULT_COLORS 1
hadd %n USE_ADIIRC_COLORS 0
hadd %n USE_CUSTOM_COLORS 0
hadd %n Custom_checkerboard 0
hadd %n Custom_bodyColor #fff
hadd %n Custom_borderColor #C0C0C0
hadd %n Custom_borderSize 0
hadd %n Custom_spinnerColor #C45528
hadd %n Custom_spinnerWidth 200
hadd %n Custom_spinnerHeight 100
hadd %n Custom_errorColor #000
}
else {
; Since config exists lets load and mirror user config to htm file
hload -mi HTAconfig %f
}

$saveConfig(SIZE_LIMIT_ENABLED,$getConfig(SIZE_LIMIT_ENABLED)).value
$saveConfig(MAX_WIDTH,$getConfig(MAX_WIDTH)).value
$saveConfig(MAX_HEIGHT,$getConfig(MAX_HEIGHT)).value
$saveConfig(BORDER,$getConfig(BORDER)).value
$saveConfig(CLOSE_ONBLUR,$getConfig(CLOSE_ONBLUR)).value
$saveConfig(WEBM_PLAYER,$getConfig(WEBM_PLAYER)).value
$saveConfig(SERVICES_ENABLED,$getConfig(SERVICES_ENABLED)).value
$saveConfig(USE_DEFAULT_COLORS,$getConfig(USE_DEFAULT_COLORS)).value
$saveConfig(USE_ADIIRC_COLORS,$getConfig(USE_ADIIRC_COLORS)).value
$saveConfig(USE_CUSTOM_COLORS,$getConfig(USE_CUSTOM_COLORS)).value
$saveConfig(Custom_checkerboard,$getConfig(Custom_checkerboard)).value
$saveConfig(Custom_bodyColor,$getConfig(Custom_bodyColor)).value
$saveConfig(Custom_borderColor,$getConfig(Custom_borderColor)).value
$saveConfig(Custom_borderSize,$getConfig(Custom_borderSize)).value
$saveConfig(Custom_spinnerColor,$getConfig(Custom_spinnerColor)).value
$saveConfig(Custom_spinnerWidth,$getConfig(Custom_spinnerWidth)).value
$saveConfig(Custom_spinnerHeight,$getConfig(Custom_spinnerHeight)).value
$saveConfig(Custom_errorColor,$getConfig(Custom_errorColor)).value
goto AdiColors

; Pull AdiIRC theme colors
:AdiColors
$saveConfig(Adi_bodyColor,$iif($readini($adiircini,Colors,Color_22),rgb( $+ $v1 $+ ),#fff)).value
$saveConfig(Adi_borderColor,$iif($readini($adiircini,Colors,Color_76),rgb( $+ $v1 $+ ),#C0C0C0)).value
$saveConfig(Adi_borderSize,$iif($readini($adiircini,General,BorderSize),$v1,0)).value
$saveConfig(Adi_spinnerColor,$iif($readini($adiircini,Colors,Color_35),rgb( $+ $v1 $+ ),#C45528)).value
$saveConfig(Adi_errorColor,$iif($readini($adiircini,Colors,Color_17),rgb( $+ $v1 $+ ),#000)).value
hsave -i HTAconfig %f
}

alias -l laughatme {
var %pos $iif($pos($1,http,1),$v1,$pos($1,www,1))
return $right($1,$calc($len($1) - %pos + 1))
}

on *:HOTLINK:*:#,?: {
;------------------------------------------------------------
; Continue if URL + left mouse click or just
; hovering cursor with ctrl key pressed
;------------------------------------------------------------

var %url $regsubex($laughatme($1),/[\51\54\175\135\76]+$/,)
tokenize 32 %url
; Default menu
hotlink -d

if ($1 isurl) {
if ($hotlink(event) == sclick || $mouse.key & 2) && ($mouse.key !& 4) {

;------------------------------------------------------------
; If script is disabled run raw url
;------------------------------------------------------------

if (!%HTA_ENABLED && $mouse.key !& 2) {
url $1
return
}

;------------------------------------------------------------
; Domains blacklist
;------------------------------------------------------------

if ($regex(BL,$1,/picpaste.com/i)) {
url $1
return
}

;------------------------------------------------------------
; Specific sites
;------------------------------------------------------------

; Youtube - https://www.youtube.com/watch?v=VKJiROKMLxs&t=60s (10m6 :x)
if ($services(Youtube) && $regex($1,/(^.*(?:youtu.be|youtube\.com\/|embed\/|watch\?v=|\&v=)([^#\&\?]*)(?:(?:\?t|&start|&t)=(\d+))?.*)/i)) {
load youtube $regml(2) $+ ? $+ $iif($regml(3),start= $+ $v1)
return
}

; Vimeo - https://vimeo.com/139094998
if ($services(Vimeo) && $regex($1,/vimeo\.com\/(\S+)/i)) {
load iframe https://player.vimeo.com/video/ $+ $regml(1) $+ ?autoplay=1
return
}

; https://www.dropbox.com/s/iuhiz9nltyw3wwk/shot_160302_154500.png?dl=0
if ($regex($1,/dropbox\.com\/s\/\S+\.(\S+)\?dl=0/i)) {
if ($services(Dropbox)) {
if ($regml(1) isin png|jpg|gif|jpeg||bmp) { load image $replace($1,?dl=0,?dl=1) | halt }
if ($services(Dropbox) && $regml(1) isin mp4|webm) { load video $replace($1,?dl=0,?dl=1) | halt }
}
else {
run $1
return
}
}

; Efukt - http://www.efukt.com/21356_Denny%27s_Waiter_Tipped_With_Blowjob.html
if ($services(Efukt) && $regex($1,/efukt\.com\/(\d+)_.+\.html/i)) {
load video http://assets.efukt.com/videos/ $+ $regml(1) $+ .mp4
return
}

; Coub - https://coub.com/view/7juc3
if ($services(Coub) && $regex($1,/coub\.com\/view\/(\w+)/i)) {
load iframe http://coub.com/embed/ $+ $regml(1) $+ ?autostart=true&originalSize=true&hideTopBar=true&startWithHD=true
return
}

; Gfycat - https://gfycat.com/MetallicPlaintiveBubblefish
if ($services(Gfycat) && $regex($1,/(gfycat\.com\/\S+)(?!(?<=webm|mp4|gif|jpg|png))$/i)) {
load gfycat $1
return
}

; Uploadpie - http://uploadpie.com/1sKdQ
if ($services(Uploadpie) && $regex($1,/(uploadpie\.com\/\S+)/i)) {
load image $1
return
}

; Prntscr/Lightshot - prntscr.com/61fgnm
if ($services(Prntscr/Lightshot) && $regex($1,/prnt\.sc|prntscr\.com\/\S+/i)) {
load image $iif(image. isin $1,$1,$remove($1,/direct) $+ /direct)
return
}

; Pasteboard - pasteboard.co/1tbFi5lL.jpg
if ($services(Pasteboard) && $regex($1,/(pasteboard\.co\/\S+)/i)) {
load image $replace($1,pasteboard.co,cdn.pbrd.co/images)
return
}

; Porngifs - porngifs.com/img/15711
if ($services(Porngifs) && $regex($1,/(?:porngifs\.com\/img\/)(\S+)/i)) {
load image http://cdn.porngifs.com/img/ $+ $regml(1)
return
}

; Pastebin - http://pastebin.com/pqSrpshr
if ($services(Pastebin) && $regex($1,/pastebin\.com\/(?!api|trends|languages|faq|tools|cookies_police|contact|dmca|scraping|pro|login|signup|search|u\/)(\S+)/i)) {
load pastebin http://pastebin.com/ $+ $iif(raw/ isin $$regml(1), $regml(1), embed_iframe/ $+ $regml(1))
return
}

;------------------------------------------------------------
; Generic medias
;------------------------------------------------------------

; Images or Videos
if ($regex($1,/^((?:http|https)\x3a\/\/)?((?(1)(?:www\.)?|www\.).+?\/(?:.+\/)?.+\.(jp(?:e)?g|gifv|gif|png|bmp|mp4|webm)(\??\S+?)?)$/iS)) {

; Local Players
if ($regml(3) == webm) {
run $iif($getConfig(WEBM_PLAYER) && $$exists($qt($v1)),$qt($v1)) $qt($regml(1) $+ $regml(2))
return
}

load $iif($regml(3) == gifv,imgur,$iif(($regml(3) isin mp4),video,image)) $iif($regml(0) == 1,http://) $+ $regml(1) $+ $iif($regml(3) == gifv,$replace($regml(2),gifv,mp4),$regml(2))
return
}

;------------------------------------------------------------
; Non media links
;------------------------------------------------------------

; not holding ctrl key
if ($mouse.key !& 2) {
url $1
}
}
}
else {
halt
}
}

alias -l load {
; path service url
run $qt($adiircdirHTAmediaViewer\HTAmediaViewer.hta) $qt($1) $qt($2)
; alt key to simulate open window in background
if ($mouse.key & 8) .timer -m 1 100 showadiirc -s
}

alias -l HTAconfig {
return $qt($adiircdirHTAmediaViewer\HTAmediaViewer.htm)
}

alias -l HTAconfigFile {
return $qt($adiircdirHTAmediaViewer\HTAconfig.ini)
}

alias HTA {
describe $$chan is using HTA Media Viewer v $+ $HTAversion $+ . Download latest version at http://dev.adiirc.com/boards/5/topics/533
}

alias -l services {
var %services $read($HTAconfig,nw,SERVICES_ENABLED=*)
if ($prop) {
write -l7 $HTAconfig SERVICES_ENABLED= $qt($iif($istok($gettok(%services,-1,34),$1,44), $remtok($gettok(%services,-1,34),$1,0,44), $addtok($gettok(%services,-1,34),$1,44)))
return
}
return $istok($gettok(%services,-1,34),$1,44)
}

alias -l saveConfig {
if ($prop == toggle) {
var %value $iif($hget(HTAconfig,$1),0,1)
hadd HTAconfig $1 %value
write -s $+ $1 $+ = $HTAconfig $1 $+ = $+ %value
}
elseif ($prop == value) {
hadd HTAconfig $1 $2
write -s $+ $1 $+ = $HTAconfig $1 $+ = $+ $iif($2 !isnum,$qt($2),$2)
if ($1 == BORDER) write -s $+ $1 $+ = $qt($adiircdirHTAmediaViewer\HTAmediaViewer.hta) $1 $+ = $+ $iif($2 !isnum,$qt($2),$2)
}
elseif ($prop == service) {
var %s SERVICES_ENABLED, %services $hget(HTAconfig,%s)
var %value $iif($istok(%services,$1,44), $remtok(%services,$1,0,44), $addtok(%services,$1,44))
hadd HTAconfig %s %value
write -s $+ %s $+ = $HTAconfig %s $+ = $+ $qt(%value)
}
if ($prop == toggleStyle) {
; Do nothing if click in an already enabled style
if ($hget(HTAconfig,$1)) return

var %options $remtok(USE_DEFAULT_COLORS USE_ADIIRC_COLORS USE_CUSTOM_COLORS,$1,1,32), %1 $gettok(%options,1,32), %2 $gettok(%options,2,32)
hadd HTAconfig $1 1
hadd HTAconfig %1 0
hadd HTAconfig %2 0
write -s $+ $1 $+ = $HTAconfig $1 $+ = $+ 1
write -s $+ %1 $+ = $HTAconfig %1 $+ =0
write -s $+ %2 $+ = $HTAconfig %2 $+ =0
}

; Save config to dir
hsave -i HTAconfig $HTAconfigFile
}

alias -l getConfig {
if (!$hget(HTAconfig)) return -
if ($prop == service) {
return $istok($gettok($hget(HTAconfig,SERVICES_ENABLED),-1,34),$1,44)
}
else {
return $hget(HTAconfig,$1)
}
}

alias -l e {
return $iif(%HTA_ENABLED,,$style(2))
}

menu channel,query {
-
HTA Media Viewer
.$iif(%HTA_ENABLED,$style(1)) Enabled:/enableToggle
.-
.$e $iif($getConfig(SIZE_LIMIT_ENABLED),$style(1)) Enable media size limit:$saveConfig(SIZE_LIMIT_ENABLED).toggle
.-
.$e Max width $chr(9) $getConfig(MAX_WIDTH):var %x $$?="Media width limit: (Default value 300)" | if (%x isnum) $saveConfig(MAX_WIDTH,%x).value
.$e Max height $chr(9) $getConfig(MAX_HEIGHT):var %x $$?="Media height limit: (Default value 300)" | if (%x isnum) $saveConfig(MAX_HEIGHT,%x).value
.-
.$e $iif($getConfig(BORDER) != none,$style(1)) Border and titlebar visible:$saveConfig(BORDER,$iif($hget(HTAconfig,BORDER) == none,thin,none)).value
.-
.$e $iif($getConfig(CLOSE_ONBLUR),$style(1)) Close image on focus loss:$saveConfig(CLOSE_ONBLUR).toggle
.-
.$e Webm player $chr(9) $nopath($getConfig(WEBM_PLAYER)):$saveConfig(WEBM_PLAYER,$$sfile($nofile($getConfig(WEBM_PLAYER)) $+ *.exe,Webm Media Player,OK)).value
.-
.$e Specific services control
..$iif($getConfig(Coub).service,$style(1)) Coub:$saveConfig(Coub).service
..$iif($getConfig(Dropbox).service,$style(1)) Dropbox:$saveConfig(Dropbox).service
..$iif($getConfig(Gfycat).service,$style(1)) Gfycat:$saveConfig(Gfycat).service
..$iif($getConfig(Efukt).service,$style(1)) Efukt:$saveConfig(Efukt).service
..$iif($getConfig(Pastebin).service,$style(1)) Pastebin:$saveConfig(Pastebin).service
..$iif($getConfig(Pasteboard).service,$style(1)) Pasteboard:$saveConfig(Pasteboard).service
..$iif($getConfig(Porngifs).service,$style(1)) Porngifs:$saveConfig(Porngifs).service
..$iif($getConfig(Prntscr/Lightshot).service,$style(1)) Prntscr/Lightshot:$saveConfig(Prntscr/Lightshot).service
..$iif($getConfig(Uploadpie).service,$style(1)) Uploadpie:$saveConfig(Uploadpie).service
..$iif($getConfig(Vimeo).service,$style(1)) Vimeo:$saveConfig(Vimeo).service
..$iif($getConfig(Youtube).service,$style(1)) Youtube:$saveConfig(Youtube).service
.-
.$e Loader style
..$iif($getConfig(USE_DEFAULT_COLORS),$style(1)) Use default:$saveConfig(USE_DEFAULT_COLORS).toggleStyle
..-
..$iif($getConfig(USE_ADIIRC_COLORS),$style(1)) Follow AdiIRC theme:$saveConfig(USE_ADIIRC_COLORS).toggleStyle
..-
..$iif($getConfig(USE_CUSTOM_COLORS),$style(1)) Use customized bellow $chr(8631):$saveConfig(USE_CUSTOM_COLORS).toggleStyle
..-
..Checkerboard background $chr(9) $iif($getConfig(Custom_checkerboard),yes,no):$saveConfig(Custom_checkerboard).toggle
..Background color $chr(9) $getConfig(Custom_bodyColor):var %x $$?="Background color: (Default value #fff)" | if (%x) $saveConfig(Custom_bodyColor,%x).value
..Border color $chr(9) $getConfig(Custom_borderColor):var %x $$?="Border color: (Default value #C0C0C0)" | $saveConfig(Custom_borderColor,%x).value
..Border size $chr(9) $getConfig(Custom_borderSize):var %x $$?="Border size: (Default value 0)" | if (%x isnum) $saveConfig(Custom_borderSize,%x).value
..Spinner animation color $chr(9) $noqt($getConfig(Custom_spinnerColor)):var %x $$?="Spinner animation color: (Default value #C45528)" | if (%x) $saveConfig(Custom_spinnerColor,%x).value
..Error message color $chr(9) $getConfig(Custom_errorColor):var %x $$?="Error message color: (Default value #000)" | if (%x) $saveConfig(Custom_errorColor,%x).value
..-
..Spinner window width $chr(9) $noqt($getConfig(Custom_spinnerWidth)):var %x $$?="Spinner window width: (Default value 200)" | if (%x) $saveConfig(Custom_spinnerWidth,%x).value
..Spinner window height $chr(9) $noqt($getConfig(Custom_spinnerHeight)):var %x $$?="Spinner window height: (Default value 200)" | if (%x) $saveConfig(Custom_spinnerHeight,%x).value
..-
..Open a preview $chr(8599):/load preview
..-
..Colors help reference (external link) $chr(8599):run http://www.w3schools.com/cssref/pr_text_color.asp
..-
.-
.About
..$style(2) Version $HTAversion by Pereba:/
..$style(2) Beta tester Jaglag:/
..-
..Advertise (/HTA):/HTA
..-
..Check for updates (/HTAupdate):/HTAupdate
..-
..Forum link:run http://dev.adiirc.com/boards/5/topics/533
-
}
(5-5/7)