手动打开关注页面并放置在后台(https://www.douyu.com/directory/myFollow) 有主播开播/更改标题时自动发送通知提醒
< Douyu斗鱼 主播开播提醒 (新) 피드백
改标题/下播/开播
/** * @description 文字转语音方法 * @public * @param { text, rate, lang, volume, pitch } object * @param text 要合成的文字内容,字符串 * @param rate 读取文字的语速 0.1~10 正常1 * @param lang 读取文字时的语言 * @param volume 读取时声音的音量 0~1 正常1 * @param pitch 读取时声音的音高 0~2 正常1 * @returns SpeechSynthesisUtterance */ function speak({ text, speechRate, lang, volume, pitch }, endEvent, startEvent) { if (!window.SpeechSynthesisUtterance) { console.warn('当前浏览器不支持文字转语音服务') return; } if (!text) { return; } const speechUtterance = new SpeechSynthesisUtterance(); speechUtterance.text = text; speechUtterance.rate = speechRate || 1; speechUtterance.lang = lang || 'zh-HK'; speechUtterance.volume = volume || 1; speechUtterance.pitch = pitch || 1; speechUtterance.onend = function() { endEvent && endEvent(); }; speechUtterance.onstart = function() { startEvent && startEvent(); }; speechSynthesis.speak(speechUtterance); return speechUtterance; } function reloadPage(){ var refreshInterval = 5 * 1000 ;//* 3600 * 24; // 设置刷新间隔时间(单位:秒) var timeFun = window.setInterval(function(){location.reload();window.clearInterval(timeFun)}, refreshInterval); } var init_flag = 0 function append_notify(res){ var status; var changed = 0; for(var each in res.data.list){ // for room status status=res.data.list[each]["show_status"]==1 && !res.data.list[each]["videoLoop"] if (!(res.data.list[each]["room_id"] in save)){ save[res.data.list[each]["room_id"]] = status; if (init_flag == 1){ changed = 1; } }else if (save[res.data.list[each]["room_id"]]!=status){ save[res.data.list[each]["room_id"]]=status var strStatus = status == 1 ? '开播了' : '下播了'; var notificationDetails = function(){ var tempUrl = res.data.list[each]["url"] speak({ text: res.data.list[each]["nickname"]+strStatus, }, function() { console.log('语音播放结束'); }, function() { console.log('语音开始播放'); }); return { text: '点击通知快速传送', title: res.data.list[each]["nickname"]+strStatus, image: res.data.list[each]["avatar_small"], //timeout: 60000, onclick: function () { console.log ("Notice clicked."); GM_openInTab(baseURL+tempUrl, false); //window.focus (); } } }() GM_notification (notificationDetails) //下播 开播都刷新 反正状态变了都刷新 changed = 1; } // for room name changing if (!(res.data.list[each]["room_id"] in save_name)){ save_name[res.data.list[each]["room_id"]] = res.data.list[each]["room_name"]; changed = 1; }else if (save_name[res.data.list[each]["room_id"]]!=res.data.list[each]["room_name"]){ save_name[res.data.list[each]["room_id"]] = res.data.list[each]["room_name"]; var notificationDetails_name = function(){ var tempUrl = res.data.list[each]["url"] speak({ text: res.data.list[each]["nickname"]+' 更改了房间标题'+res.data.list[each]["room_name"], }, function() { console.log('语音播放结束'); }, function() { console.log('语音开始播放'); }); return { text: res.data.list[each]["room_name"], title: res.data.list[each]["nickname"]+' 更改了房间标题', image: res.data.list[each]["avatar_small"], //timeout: 60000, onclick: function () { console.log ("Notice clicked."); GM_openInTab(baseURL+tempUrl, false); //window.focus (); } } }() GM_notification (notificationDetails_name) changed = 1; } } if (init_flag != 0 && changed == 1){ reloadPage(); } init_flag = 1 console.log ('Following rooms checked'); }
@hlc1209
谢谢commit。目前本项目尚未实现设置界面,故不宜添加过多功能。 强烈建议您自己创建项目
댓글을 남기려면 로그인하세요.
改标题/下播/开播
提醒