修复多次烦人的通知

This commit is contained in:
woohoo 2022-02-22 20:55:51 +08:00
parent 229d22fe43
commit 1262fd17c7

View File

@ -1,8 +1,8 @@
// ==UserScript== // ==UserScript==
// @lastmodified 202202222023 // @lastmodified 202202222055
// @name 芜湖助手 // @name 芜湖助手
// @namespace WOOH // @namespace WOOH
// @version 0.3.18 // @version 0.3.19
// @description 托恩,起飞! // @description 托恩,起飞!
// @author Woohoo[2687093] Sabrina_Devil[2696209] // @author Woohoo[2687093] Sabrina_Devil[2696209]
// @match https://www.torn.com/* // @match https://www.torn.com/*
@ -23,13 +23,18 @@
if (window.WHTRANS) return; if (window.WHTRANS) return;
window.WHTRANS = true; window.WHTRANS = true;
// 版本 // 版本
const version = '0.3.18'; const version = '0.3.19';
// 修改历史 // 修改历史
const changelist = [ const changelist = [
{ {
todo: true, todo: true,
cont: `翻译baza npc商店、imarket、imarket搜索结果`, cont: `翻译baza npc商店、imarket、imarket搜索结果`,
}, },
{
ver: '0.3.19',
date: '20220222',
cont: `修复多次烦人的通知`,
},
{ {
ver: '0.3.18', ver: '0.3.18',
date: '20220222', date: '20220222',
@ -9080,8 +9085,10 @@ text-decoration:none;
// 浏览器通知 // 浏览器通知
try { try {
if (Notification.permission === 'granted' && sysNotify) { if (Notification.permission === 'granted' && sysNotify) {
const last_notify = getWhSetting('lastNotify');
const last_notify_date = new Date(last_notify);
const date_local_string = `[${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}]\r` const date_local_string = `[${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}]\r`
if (date.getTime() - getWhSetting('lastNotify') > 3000) { if (!!last_notify_date || date - last_notify_date > 3000) {
new Notification('芜湖助手', { new Notification('芜湖助手', {
body: date_local_string + notify_contain.msgInnerText, body: date_local_string + notify_contain.msgInnerText,
requireInteraction: false requireInteraction: false