- // Step 1: add a container box to store song urls
- var lc = document.body.appendChild(document.createElement("ol"));
- // Step 2: set styles for the container
- lc.style.CSSText="position:fixed;right:0px;bottom:0px;background:white;border:1px solid green;width:300px;height:200px;overflow:auto";
- // Step 3: override the original log method(you can store the original function reference if needed)
- var bs = cs.p;
- cs.p=function(msg){
- if(msg.indexOf("getSongUrl 1") === 0){
- var li = lc.appendChild(document.createElement("li"));
- var url = msg.substr(msg.indexOf(":")+1);
- var title= document.querySelector("#divsonginfo .music_name").title || url;
- li.innerhtml = "<input type='text' value='" + title + "' onfocus='this.select()' style='border: 1px solid; margin-right: 5px;'><a style='text-decoration:underline' target='_blank' href='" + url + "'>" + title + "</a>";
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/031220137669.html
来源: http://www.codesnippet.cn/detail/031220137669.html