您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Notifies you whenever it's your turn to draw. Notifications must be allowed.
当前为
// ==UserScript== // @name Choose A Word // @namespace https://greasyfork.org/users/281093 // @match https://sketchful.io/* // @grant none // @version 1.0 // @author Bell // @description Notifies you whenever it's your turn to draw. Notifications must be allowed. // jshint esversion: 6 // ==/UserScript== (function checkNotificationPerm() { if (Notification.permission === "granted") { console.log("Notifications allowed"); } else if (Notification.permission !== "granted") { Notification.requestPermission().then(function(permission) { if (permission === "granted") { console.log("Notification ermission granted"); } else { console.log("Permission denied"); } }); } })(); const callback = function(mutationsList, observer) { for (let mutation of mutationsList) { if (mutation.addedNodes[0] && mutation.addedNodes[0].innerHTML.includes("Choose")) { if (!tabFocused) { notify(); } } } }; let tabFocused = true; const playerList = document.querySelector("#gameSticky"); const observer = new MutationObserver(callback); const config = { attributes: false, childList: true, subtree: true }; observer.observe(playerList, config); function notify() { if (Notification.permission === "granted") { let notification = new Notification("Your Turn", { icon: "https://sketchful.io/res/logo/pencils%20optimized.png", body: "Click the notification to return to the game.", requireInteraction: true, }); notification.onclick = function() { window.focus(); notification.close(); }; } else { console.log("Notifications are blocked."); } } function onBlur() { tabFocused = false; } function onFocus() { tabFocused = true; } if ( /*@cc_on!@*/ false) { // check for Internet Explorer document.onfocusin = onFocus; document.onfocusout = onBlur; } else { window.onfocus = onFocus; window.onblur = onBlur; }