// ==UserScript==
// @name 关于我们提醒通知
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.baidu.com/
// @icon https://www.google.com/s2/favicons?sz=64&domain=5054399.com
// @grant GM_notification
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
function formatDate(offset, format) {
const today = new Date();
const relativeDate = new Date(today)
relativeDate.setDate(today.getDate() + offset)
const year = relativeDate.getFullYear();
const month = String(relativeDate.getMonth() + 1).padStart(2, '0');
const day = String(relativeDate.getDate()).padStart(2, '0');
const hour = String(relativeDate.getHours()).padStart(2, '0');
const minute = String(relativeDate.getMinutes()).padStart(2, '0');
const second = String(relativeDate.getSeconds()).padStart(2, '0');
// 根据传入的格式参数,返回不同格式的日期字符串
switch (format) {
case 'yyyy-MM-dd':
return ${year}-${month}-${day}
;
case 'yyyy-MM-dd HH:mm:ss':
return ${year}-${month}-${day} ${hour}:${minute}:${second}
;
case 'yyyy/MM/dd':
return ${year}/${month}/${day}
;
case 'yyyy/MM/dd HH:mm:ss':
return ${year}/${month}/${day} ${hour}:${minute}:${second}
;
default:
return ${hour}:${minute}:${second}
;
}
}
function H5提醒(文案){
// 显示通知
GM_notification({
text: 文案 , // 提示信息内容
title: '提示', // 提示信息标题
timeout: 1000, // 提示信息显示时间(毫秒),默认为4000毫秒
});
console.log("结束"+formatDate(0))
}
async function 延迟执行(func,文案, 秒) {
await new Promise((resolve) => setTimeout(resolve, 秒 * 1000));
func(文案)
console.log("提醒"+formatDate(0))
}
//=========================================================================================================
if(document.location.href.includes('https://www.baidu.com/')){
延迟执行(H5提醒,"超时", 0)
}
哥哥们,麻了,这个油猴的H5提醒函数,老是不准时,我用延时函数执行和用点击触发,都是要等好久的,要么就是集中一个时间段弹出来。各位哥哥帮忙看下