Last active
January 10, 2016 18:39
-
-
Save bo33b/092f3c0cdb47365ffd9d to your computer and use it in GitHub Desktop.
Simple and lightweight vk.com music download enabler userscript for Greasemonkey
This file contains hidden or 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 VK Music Download | |
// @namespace bo33b | |
// @description Simple and lightweight VK music download enabler. | |
// @downloadURL https://gist.github.com/bo33b/092f3c0cdb47365ffd9d/raw/vkmusic.user.js | |
// @version 3.4 | |
// @include http://vk.com/* | |
// @include https://vk.com/* | |
// @grant none | |
// ==/UserScript== | |
setInterval(function() { | |
var audio = document.getElementsByClassName("play_btn_wrap"), i = audio.length-1, node, file, song, a; | |
for (; !audio[i].previousElementSibling && i>-1; i--) { | |
node = audio[i].parentNode; | |
file = node.getElementsByTagName("input")[0].value.split("?")[0]; | |
song = node.nextElementSibling.textContent.slice(0,-20).trim().replace("–","-")+".mp3"; | |
a = document.createElement("a"); | |
a.setAttribute("onclick","event.cancelBubble=1;"); | |
a.style = "float:left;font-size:large;margin: 5px -13px"; | |
a.title = "Right-click, \"Save Link As...\" to download"; | |
a.target = "_blank"; | |
a.innerHTML = "♫"; | |
a.download = song; | |
a.href = file; | |
node.insertBefore(a,node.childNodes[1]); | |
} | |
},1100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment