Skip to content

Instantly share code, notes, and snippets.

@xavierskip
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xavierskip/861d9f3569142a1ec1e7 to your computer and use it in GitHub Desktop.
Save xavierskip/861d9f3569142a1ec1e7 to your computer and use it in GitHub Desktop.
doubanFM searching in netease cloud music
// ==UserScript==
// @name doubanFM2NetEase
// @namespace http://xavierskip.com/
// @version 0.1
// @description doubanFM searching in netease cloud music
// @author xavier skip
// @match http://douban.fm/*
// @grant none
// ==/UserScript==
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
function getSong(){
var info = window.localStorage.getItem('bubbler_song_info');
return JSON.parse(info);
}
function generateSearchURL(song){
//不知道为什么豆瓣存储的信息song.artist和song.album是一样的
var info = encodeURIComponent(song.song_name+" "+song.artist);
return "http://music.163.com/#/search/m/?s="+info
}
function Ahref(){
var song = getSong();
var url = generateSearchURL(song);
return url;
}
var a = document.createElement("a");
var content = document.querySelector(".send-song-to-phone");
a.id = "netease";
a.href=Ahref();
a.target="_blank";
a.innerText = "在网易云音乐中查找当前播放歌曲";
a.addEventListener("click",function(e){
a.href = Ahref();
},false);
content.appendChild(a);
content.style.zIndex = 50;
addGlobalStyle('#netease { color: #888;z-index:300;} #netease:hover{background: 0;color: #5b9;}');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment