-
-
Save DonPramis/f9dced54606ac25c92fd72e179caefdb to your computer and use it in GitHub Desktop.
Script for downloading audio and video files from the vk.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name VKGetLink | |
// @description Script for downloading audio and video files from the vk.com. Based on Ivan Snegirev's VK-Downloader http://userscripts-mirror.org/scripts/show/151571 | |
// @author Mist Poryvaev | |
// @version 1.0.2 | |
// @include https://*vk.com/* | |
// @grant none | |
// ==/UserScript== | |
function audio() | |
{ | |
var main_div=document.getElementsByClassName("area clear_fix"); | |
for(var i=0;i<main_div.length;i++) | |
{ | |
if(main_div[i].parentNode.firstChild.href) | |
{ | |
main_div[i].parentNode.firstChild.style.top=main_div[i].getElementsByClassName("play_new")[0].offsetTop+"px"; | |
continue; | |
} | |
var _mp3_=main_div[i].getElementsByTagName("input")[0].value.split(",")[0].split("?")[0]; | |
var _b_=main_div[i].getElementsByTagName("b")[0]; | |
var _top_=document.getElementById(main_div[0].parentNode.id.replace("audio","play")).offsetTop+"px"; | |
var _t_=main_div[i].getElementsByClassName("play_new")[0].offsetTop+"px"; | |
var _info_; | |
if (main_div[i].getElementsByClassName("info").length != 0) | |
{ | |
_info_ = main_div[i].getElementsByClassName("info")[0] | |
} | |
else | |
{ | |
_info_ = main_div[i].getElementsByClassName("info fl_l")[0]; | |
} | |
var _a_tmp_ = _info_.getElementsByTagName("a"); | |
var _title_ = _a_tmp_[0].innerHTML + " - "; | |
if (_a_tmp_.length == 1) | |
{ | |
_title_ = _title_ + _info_.getElementsByTagName("span")[0].innerHTML; | |
} | |
else | |
{ | |
_title_ = _title_ + _a_tmp_[1].innerHTML; | |
} | |
var _a_=document.createElement("a"); | |
_a_.href=_mp3_; | |
_a_.target="_blank"; | |
_a_.innerHTML=" ▼"; | |
_a_.download =_title_ + ".mp3"; | |
_a_.style.zIndex="10"; | |
_a_.style.left="30px"; | |
_a_.style.top=_t_; | |
_a_.style.position="absolute"; | |
_a_.style.color="white"; | |
_a_.style.backgroundColor="#5e82a8"; | |
_a_.style.border="#395A7C"; | |
_a_.style.width="16px"; | |
_a_.style.height="16px"; | |
main_div[i].parentNode.insertBefore(_a_,main_div[i].parentNode.firstChild); | |
_b_.style.paddingLeft="25px"; | |
} | |
} | |
function video() | |
{ | |
if(document.getElementsByClassName("video_box_wrap")[0] && !document.getElementById('download') && document.getElementById('video_player').tagName!='IFRAME') | |
{ | |
var inner_video=""; | |
var f=encodeURI(unescape(document.getElementsByClassName("video_box_wrap")[0].innerHTML.split(" ")[8].split('"')[1].replace(/amp;/g,""))); | |
var flashvars=f.split("&"); | |
var o = new Object(); | |
var name=new Array(); | |
var content=new Array(); | |
var title = document.getElementById("mv_title").innerHTML.replace("\"",""); | |
for(var c=0;c<=flashvars.length-1;c++) | |
{ | |
name[c]=flashvars[c].split("=")[0]; | |
content[c]=flashvars[c].split("=")[1]; | |
} | |
for(var c2=0;c2<=name.length;c2++) | |
{ | |
o[name[c2]]=content[c2]; | |
} | |
var _url_; | |
var _size; | |
if (o.url1080) | |
{ | |
_url_ = o.url1080.split("?")[0]; | |
_size_ = "1080"; | |
} | |
else | |
if (o.url720) | |
{ | |
_url_ = o.url720.split("?")[0]; | |
_size_ = "720"; | |
} | |
else | |
if (o.url480) | |
{ | |
_url_ = o.url480.split("?")[0]; | |
_size_ = "480"; | |
} | |
else | |
if (o.url360) | |
{ | |
_url_ = o.url360.split("?")[0]; | |
_size_ = "360"; | |
} | |
else | |
if (o.url240) | |
{ | |
_url_ = o.url240.split("?")[0]; | |
_size_ = "240"; | |
} | |
if (_url_.length != 0) | |
{ | |
inner_video="<a style='color:white;background-color:#5e82a8;padding:5px 5px 2px 5px;border:#395A7C;' target='_blank' href='"+_url_+"' download='"+title+"'>"+_size_+"▼</a> "; | |
var video_download=document.createElement("div"); | |
video_download.style.width="auto"; | |
video_download.style.height="auto"; | |
video_download.style.paddingBottom="5px"; | |
video_download.id="download"; | |
video_download.innerHTML=inner_video; | |
document.getElementById("mv_more").parentNode.appendChild(video_download); | |
} | |
} | |
} | |
setInterval(function() | |
{ | |
if(document.getElementsByClassName("area clear_fix").length!=0) | |
{ | |
audio(); | |
} | |
if(document.getElementById('video_player')) | |
{ | |
video(); | |
} | |
}, 400); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment