// ==UserScript== // @name bilibili notify // @namespace heroesm // @include http://live.bilibili.com/feed/getList/1 // @include https://live.bilibili.com/feed/getList/1 // @include http://api.live.bilibili.com/ajax/feed/list* // @include https://api.live.bilibili.com/ajax/feed/list* // @version 1.0.6 // @grant none // // @description 自动监听bilibili直播推送信息,当所关注者开启直播时自动打开直播网页的javascript脚本。 // @downloadURL https://update.greasyfork.icu/scripts/22383/bilibili%20notify.user.js // @updateURL https://update.greasyfork.icu/scripts/22383/bilibili%20notify.meta.js // ==/UserScript== function main(){ "use strict"; var sAltAPI = '//api.live.bilibili.com/ajax/feed/list?pagesize=30&page=1'; var running = true; var rProFilter, rConFilter; var rFilter = /./; var sMode = 'pro'; var aTimer = []; var aAltRoomid = null; var sTitle = ''; var isBuilt = false; function reload(){ run() } 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(){ reload() }, 30000); aTimer.push(timer); document.$('#pause').style.display = 'unset'; document.$('#start').style.display = 'none'; document.title = sTitle; 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'; sTitle = document.title; document.title = '已暂停'; } function update(){ try{ var sCon = document.$('#con').value.trim(); localStorage.bilinotify_con = sCon; rConFilter = new RegExp(sCon); var sPro = document.$('#pro').value.trim(); localStorage.bilinotify_pro = sPro; rProFilter = new RegExp(sPro); } 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'); var sName = item.nickname || item.uname if(con ^ rFilter.test(sName)){ window.open(item.link + '###', sName); } } function build(){ if (isBuilt){ return } isBuilt = true; var 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', [ '