// ==UserScript== // @name bilibili notify // @namespace heroesm // @include http://live.bilibili.com/feed/getList/1 // @version 1 // @grant none // // @description 自动监听bilibili直播推送信息,当所关注者开启直播时自动打开直播网页的javascript脚本。 // @downloadURL none // ==/UserScript== function main(){ var running = true; var rProFilter, rConFilter; var rFilter = /./; var sMode = 'pro'; var aTimer = []; function prepare(){ Document.prototype.$ = Document.prototype.querySelector; Element.prototype.$ = Element.prototype.querySelector; Document.prototype.$$ = Document.prototype.querySelectorAll; Element.prototype.$$ = Element.prototype.querySelectorAll; } function start(){ var timer = setTimeout(function(){ window.location.reload(); }, 30000); aTimer.push(timer); document.$('#pause').style.display = 'unset'; document.$('#start').style.display = 'none'; return timer; } function stop(){ var nTimer = aTimer.pop(); while (nTimer){ clearTimeout(nTimer); nTimer = aTimer.pop(); } document.$('#pause').style.display = 'none'; document.$('#start').style.display = 'unset'; } function update(){ try{ localStorage.bilinotify_con = document.$('#con').value; rConFilter = new RegExp(document.$('#con').value); localStorage.bilinotify_pro = document.$('#pro').value; rProFilter = new RegExp(document.$('#pro').value); }catch(e){console.log(e);} localStorage.bilinotify_mod = sMode = document.$('input[name=mode]:checked').value; if (sMode == 'pro'){ rFilter = rProFilter; } else{ rFilter = rConFilter; } } function checkopen(item){ var con = Boolean(sMode == 'con'); if(con ^ rFilter.test(item.nickname)){ window.open(item.link + '###', item.nickname); } } function build(){ style = document.createElement('style'); style.id = 'bilinotify_css'; style.innerHTML = [ 'input[type=text] {width: 50%;}' ].join('\n'); document.head.appendChild(style); document.body.insertAdjacentHTML( 'beforeend', [ '