/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// ==UserScript== // @name Download audio from http://vkontakte.ru/ // @version 2.00 // @date 2009-03-17 Tue 09:41 // @author dMitry Alexandrov <[email protected]> // @include http://vkontakte.ru/audio* // @include http://vkontakte.ru/gsearch.php?*section=audio* // @include http://vkontakte.ru/gsearch.php?section=audio* // ==/UserScript== function afterFunc() { for (var i=0,el,els=document.selectNodes('//img[@class="playimg"]');el=els[i++];) { var lnk=document.createElement("A"); lnk.innerHTML = '\u0441\u043a\u0430\u0447\u0430\u0442\u044c \u00bb'; lnk.href=el.getAttribute('onclick').replace(/.*operate\((\d+),(\d+),(\d+),'([0-9a-f]+)',(\d+)\).*/,'http://cs$2.vkontakte.ru/u$3/audio/$4.mp3'); lnk.setAttribute('style', 'display: block !important; float: none !important; font: icon !important; margin: 15px 0 0 0 !important; padding: 0 !important; text-align: left !important;', false); (el.parentNode.nextSibling || el.parentNode).appendChild(lnk); } } window.addEventListener('DOMContentLoaded', afterFunc, false); window.opera.addEventListener('BeforeJavascriptURL', function (e) { if( e.source.match(/getPageContent\(\d+,\s*\d+\)/)) e.source = e.source.replace(/getPageContent\(\s*(\d+)\s*,\s*(\d+)\s*\);?/,'getPageContent\($1,$2,afterFunc)'); }, false ); /** Link to create M3U playlist */ window.addEventListener('DOMContentLoaded', function(){ var a=document.createElement('A'); a.href='javascript:void(0);'; a.innerHTML="playlist"; a.title='Create m3u playlist'; a.onclick=function(){ var list="#EXTM3U\n"; function getTitle(el){return el.innerHTML.replace(/(^\s+)|(\s+$)/gm,'')}; function getSecs(el){ if (el && el.firstChild) { var x=el.firstChild.nodeValue.split(':') return 60*parseInt(x[0],10) + parseInt(x[1],10); }else return 0; }; for (var i=0,el,els=document.selectNodes('//a[@href]');el=els[i++];) { if (/\.mp3$/i.test(el.href)) { var file=el.href; var td=el.parentNode; //alert(td.tagName); var title=getTitle(td.firstChild); var duration=getSecs(td.selectSingleNode('./div[@class="duration"]')); list+="#EXTINF:"+duration+","+title+"\n"+file+"\n"; } } var w=window.open("about:blank","VKPlayList",'width=450,height=450,top=5,left=70,scrollbars=yes,status=no'); w.document.open(); w.document.write('<pre>'+list+'</pre>'); w.document.close(); return false; }; (document.getElementById('searchContent')||document.getElementById("searchAudio")||document.getElementById('audioSearch')).appendChild(a); }, false);
URL: http://vkontakte.ru/audio