您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Notification script for Arena of Glory
当前为
- // ==UserScript==
- // @name AoG Notifications
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description Notification script for Arena of Glory
- // @author Xortrox
- // @match https://play.arenaofglory.io/*
- // @icon https://play.arenaofglory.io/favicon.ico
- // @grant none
- // @license MIT
- // ==/UserScript==
- (async function() {
- const icon = 'https://play.arenaofglory.io/favicon.ico';
- const gameTitle = 'Arena of Glory';
- /** How frequently to scan for changes on the website (in milliseconds) */
- const notifyTimerInterval = 60000;
- await hasPermission();
- setInterval(() => {
- const notificationElements = document.querySelectorAll('.adventure-done-component .go-button-wrapper .button label');
- /** We send notification only once if any adventures are claimable */
- if (notificationElements && notificationElements.length > 0) {
- for (let element of notificationElements) {
- const text = element.innerText;
- const textLower = text.toLowerCase();
- if (textLower.includes('claim') && !textLower.includes('claimed')) {
- notify('You have at least one adventure to claim');
- }
- break;
- }
- }
- }, notifyTimerInterval);
- function notify(text) {
- hasPermission().then(function (result) {
- if (result === true) {
- let popup = new window.Notification(gameTitle, { body: text, icon: icon });
- popup.onclick = function () {
- window.focus();
- }
- }
- });
- }
- function hasPermission() {
- return new Promise(function (resolve) {
- if ('Notification' in window) {
- if (window.Notification.permission === 'granted') {
- resolve(true);
- } else {
- window.Notification.requestPermission().then(function (permission) {
- if (permission === 'granted') {
- resolve(true);
- } else {
- resolve(false);
- }
- });
- }
- } else {
- resolve(true);
- }
- });
- }
- })();