// ==UserScript== // @name Moe-FM Fav-Songs Random Play // @version 1.3 // @author 864907600cc // @description 随机播放萌否电台中收藏的音乐的小脚本( ̄▽ ̄")…… // @include http://moe.fm/home/* // @include http://moe.fm/listen* // @exclude http://moe.fm/listen/playlist* // @icon http://nyan.moefou.org/avatar_group/00/00/000074.jpg // @grant none // @namespace https://greasyfork.org/users/141 // @downloadURL none // ==/UserScript== if(!window.localStorage.getItem('rp-setting'))window.localStorage.setItem('rp-setting','{"s1":1,"s2":0,"s3":50,"s4":0}'); var rps=JSON.parse(window.localStorage.getItem('rp-setting')); if(rps.s4==null||rps.s4==undefined)rps.s4=1; if(/moe.fm\/listen/.test(window.location.href)){ if(window.sessionStorage.length>0)window.sessionStorage.clear(); var clickb=document.createElement('li'), issetting=0; clickb.innerHTML='随机播放收藏曲目设置'; clickb.className='b-b'; document.getElementsByClassName('radio-menu-container')[0].getElementsByTagName('ul')[0].appendChild(clickb); clickb.getElementsByTagName('span')[0].onclick=function(event){ issetting=1; setting(); } clickb.onclick=function(event){ if(issetting!=1){ if(!window.localStorage.getItem('rp-favsong-data')){ window.sessionStorage.setItem('rp-fetch','true'); /*rps.s4==0?*/getting()/*:getting_xml()*/; } else if(rps.s1==1){ if(rps.s2==1)window.localStorage.removeItem('rp-favsong-data'); window.sessionStorage.setItem('rp-fetch','true'); /*rps.s4==0?*/getting()/*:getting_xml()*/; } else run(); } } } if(window.sessionStorage.getItem('rp-fetch'))getting(); function getting(){ var user=document.getElementsByClassName('navi-panel-content')[0].getElementsByTagName('a')[0].href.split('moe.fm/home/')[1], src='http://moe.fm/home/'+user+'/songs'; if(!window.sessionStorage.getItem('rp-page')){ window.sessionStorage.setItem('rp-page','1'); window.location.href=src; } else{ if(!window.sessionStorage.getItem('rp-lastpage')){ var page_a=document.getElementsByClassName('pages')[0].getElementsByTagName('a'); var lastpage=page_a[page_a.length-1].href.split('page/')[1]; window.sessionStorage.setItem('rp-lastpage',lastpage); } var _=document.createElement('div'); _.id='rp_tips'; document.body.appendChild(_); _.innerHTML='

正在获取第 '+window.sessionStorage.getItem('rp-page')+' 页数据,共 '+window.sessionStorage.getItem('rp-lastpage')+' 页,请稍候......

'; if(!window.localStorage.getItem('rp-favsong-data'))window.localStorage.setItem('rp-favsong-data',''); var button=document.getElementsByClassName('fav-song'); for(var i=0;i

有疑问、 bug 反馈?告诉我吧~~( ´ ▽ ` )ノ 我在萌否@864907600cc 贴吧@864907600cc (常驻 chrome 吧),感谢支持~~> <

'; document.body.appendChild(s_container); if(rps.s1==1)document.getElementById('abc1').setAttribute('checked','checked'); if(rps.s2==1)document.getElementById('abc2').setAttribute('checked','checked'); if(rps.s3)document.getElementById('abc3').setAttribute('value',rps.s3); //if(rps.s4==1)document.getElementById('abc4').setAttribute('checked','checked'); document.getElementById('abcb1').onclick=function(event){ window.localStorage.removeItem('rp-favsong-data'); alert('数据已清除...在下次随机播放时会重新获取并储存收藏曲目数据...'); } document.getElementById('abcb2').onclick=function(event){ if(rps.s2==1)window.localStorage.removeItem('rp-favsong-data'); window.sessionStorage.setItem('rp-fetch','true'); rps.s4==0?getting():getting_xml(); } document.getElementById('abcs').onclick=function(event){ var abc=new Object(); if(document.getElementById('abc1').checked)abc.s1=1;else abc.s1=0; if(document.getElementById('abc2').checked)abc.s2=1;else abc.s2=0; if(document.getElementById('abc3').value)abc.s3=document.getElementById('abc3').value; else{ abc.s3=50; alert('随机播放音乐数设置有误...已设置为默认值...'); } //if(document.getElementById('abc4').checked)abc.s4=1;else abc.s4=0; window.localStorage.setItem('rp-setting',JSON.stringify(abc)); issetting=0; s_container.outerHTML=''; s_bg.outerHTML=''; rps=JSON.parse(window.localStorage.getItem('rp-setting')); } } if(!window.localStorage.getItem('rp_version')||window.localStorage.getItem('rp_version')!='1.3'){ if(!window.localStorage.getItem('rp_version'))var l_version='1.0'; else var l_version=window.localStorage.getItem('rp_version'); var tips=document.createElement('script'); tips.src='http://ext.ccloli.com/moe-fm/rp-update-tips?version='+l_version; document.body.appendChild(tips); window.localStorage.setItem('rp_version','1.3'); }