您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
This script is intended to work with @require only. Provides class AutomatedButtonTextNotifier
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greatest.deepsurf.us/scripts/438801/1010216/UserScript%20Automated%20Button%20Text%20Notifier.js
您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
- // ==UserScript==
- // @namespace Xortrox/UserScripts/AutomatedButtonTextNotifier
- // @name UserScript Automated Button Text Notifier
- // @version 0.1
- // @description This script is intended to work with @require only. Provides class AutomatedButtonTextNotifier
- // @author Xortrox,
- // @match *
- // @esversion: 6
- // @license MIT
- // ==/UserScript==
- class AutomatedButtonTextNotifier {
- constructor(options) {
- this.icon = options.icon || '';
- this.title = options.title || 'No Title Specified';
- /** Looks for this pattern: <button class="button"><label></label></button */
- this.selector = options.selector;
- /** How frequently to scan for changes on the website (in milliseconds) */
- this.notificationInterval = options.interval;
- this.scanConfiguration = options.config;
- if (!this.selector) {
- this.error('Error: No selector specified for AutomatedButtonTextNotifier');
- }
- }
- async init() {
- await window.UserScript.Notifications.askPermission();
- this.interval = setInterval(this.scan, this.notificationInterval);
- }
- scan() {
- const notificationElements = document.querySelectorAll(buttonSelector);
- /** 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();
- for (const config of this.scanConfiguration) {
- let includesText = false;
- let excludesText = false;
- for (const includeText of config.includes) {
- if (textLower.includes[includeText]) {
- includesText = true;
- break;
- }
- }
- if (config.excludes?.length > 0) {
- for (const excludeText of config.includes) {
- if (!textLower.includes[excludeText]) {
- excludesText = true;
- break;
- }
- }
- }
- let canShowNotification = includesText;
- if (config.excludes?.length > 0) {
- canShowNotification = canShowNotification && excludesText;
- }
- if (canShowNotification) {
- window.UserScript.Notifications.notify(this.title, config.notificationText, this.icon);
- break;
- }
- }
- }
- }
- }
- error(error) {
- alert(error);
- console.error(new Error(error));
- }
- }