您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Notifies when a new match is starting using a desktop notification
// ==UserScript== // @name SMB35 Game notifier // @namespace https://github.com/LuisMayo/general-userscripts // @version 1.0 // @description Notifies when a new match is starting using a desktop notification // @author LuisMayo // @match https://smb35server.com:20002/dashframes // @icon https://www.google.com/s2/favicons?sz=64&domain=smb35server.com // @grant none // ==/UserScript== (function() { 'use strict'; const CHECK_ID = 'luis-desktop-notify'; let dashframeWindow; let lastGame; const newGameDetected = () => { let isNewGame = false; const games = Array.from(dashframeWindow.document.querySelectorAll('table > tbody > tr > td:first-child')); if (games.length > 0) { const gamesId = games.map(game => +game.textContent); const largerId = Math.max(...gamesId); if (!lastGame || largerId > lastGame) { lastGame = largerId; isNewGame = true; } } return isNewGame; } const checkForGames = () => { if (document.getElementById(CHECK_ID).checked && newGameDetected()) { new Notification('New match started'); } } const onNotifyCheckChanged = (ev) => { if (ev.target.checked && Notification.permission === 'default') { Notification.requestPermission(); } } const main = () => { dashframeWindow = document.getElementById("dashframe").contentWindow; const check = document.createElement('input'); check.type = 'checkbox'; check.id = CHECK_ID; check.addEventListener('change', onNotifyCheckChanged); const label = document.createElement('label'); label.htmlFor = CHECK_ID; label.textContent = 'Send a desktop notification when a new match starts matchmaking'; const div = document.createElement('div'); div.appendChild(check); div.appendChild(label); document.getElementById('soundOption').appendChild(div); setInterval(checkForGames, 10000); } setTimeout(main, 2000); })();