// ==UserScript== // @name ffffoundtape.com: Add mp3 Link // @include http://ffffoundtape.com/ // @include http://ffffoundtape.com/* // ==/UserScript== (function() { var ICON = ''; setTimeout(function() { if (window.AutoPagerize) { window.AutoPagerize.addFilter(filter); } }, 0); addMp3Link(document); function filter(docs) { docs.forEach(addMp3Link); } function addMp3Link(doc) { Array.forEach(doc.getElementsByTagName('h3'), function(e) { var id = e.id.match(/track_name_(\d+)/)[1]; GM_xmlhttpRequest({ method : 'get', url : 'http://ffffoundtape.com/trackplaylist.php?i=' + id, onload : function(res) { var responseText = res.responseText; var xml = new XML(encodeEntities(responseText)); var playlist = new Namespace(xml.name().uri) var url = xml.playlist::trackList.playlist::track.playlist::location; var a = document.createElement('a'); a.href = url; a.innerHTML = ICON; e.appendChild(a); } }); }); } function encodeEntities(str) { return str .replace('&', '&'); } })();