GameMale
登陆 / 注册 搜索

USERCENTER

SEARCHSITE

搜索

查看: 3932|回复: 66
收起左侧

[实用工具] 【脚本】悬浮显示时间

  [复制链接] |关注本帖

GM活动员

法师 · I

Futūrum(未来)果体76裸体克里斯炙热的格拉迪欧拉斯凯登‧阿兰科亚瑟‧摩根永远的克叔【夏日限定】夏日的泰凯斯亭亭如盖

     楼主| Makima 发表于 2025-10-6 00:20:18 | 显示全部楼层 |阅读模式 |取消关注该作者的回复
    双击锁定/解锁
    抢勋章的时候可以看时间,平时关闭就好了

    @Name @Match
    1. // ==UserScript==
    2. // @name         悬浮显示时间
    3. // @version      0.1
    4. // @author       MKM
    5. // @match        *://*/*
    6. // @grant        GM_setValue
    7. // @grant        GM_getValue
    8. // ==/UserScript==

    9. (function() {
    10.     'use strict';

    11.     if (document.getElementById('beijing-time-floating')) {
    12.         return;
    13.     }

    14.     const timeDisplay = document.createElement('div');
    15.     timeDisplay.id = 'beijing-time-floating';

    16.     const savedPosition = GM_getValue('timePosition', { top: 20, right: 20 });
    17.     const isLocked = GM_getValue('timeLocked', false);

    18.     timeDisplay.style.cssText = `
    19.         position: fixed;
    20.         top: ${savedPosition.top}px;
    21.         right: ${savedPosition.right}px;
    22.         background: rgba(0, 0, 0, 0.8);
    23.         color: #fff;
    24.         padding: 10px 15px;
    25.         border-radius: 20px;
    26.         font-family: 'Microsoft YaHei', Arial, sans-serif;
    27.         font-size: 14px;
    28.         font-weight: bold;
    29.         z-index: 9999;
    30.         box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    31.         backdrop-filter: blur(5px);
    32.         border: 1px solid rgba(255, 255, 255, 0.2);
    33.         cursor: ${isLocked ? 'default' : 'move'};
    34.         user-select: none;
    35.         transition: all 0.3s ease;
    36.         min-width: 180px;
    37.         text-align: center;
    38.     `;

    39.     if (isLocked) {
    40.         timeDisplay.style.border = '1px solid #4CAF50';
    41.     }

    42.     timeDisplay.addEventListener('mouseenter', function() {
    43.         this.style.background = 'rgba(0, 0, 0, 0.9)';
    44.         this.style.transform = 'scale(1.05)';
    45.     });

    46.     timeDisplay.addEventListener('mouseleave', function() {
    47.         this.style.background = 'rgba(0, 0, 0, 0.8)';
    48.         this.style.transform = 'scale(1)';
    49.     });

    50.     timeDisplay.addEventListener('dblclick', function(e) {
    51.         e.preventDefault();
    52.         e.stopPropagation();

    53.         const newLockState = !GM_getValue('timeLocked', false);
    54.         GM_setValue('timeLocked', newLockState);

    55.         if (newLockState) {
    56.             this.style.cursor = 'default';
    57.             this.style.border = '1px solid #4CAF50';
    58.         } else {
    59.             this.style.cursor = 'move';
    60.             this.style.border = '1px solid rgba(255, 255, 255, 0.2)';
    61.         }
    62.     });

    63.     function updateTime() {
    64.         const now = new Date();
    65.         const beijingTime = new Date(now.getTime() + (8 * 60 * 60 * 1000));

    66.         const year = beijingTime.getUTCFullYear();
    67.         const month = String(beijingTime.getUTCMonth() + 1).padStart(2, '0');
    68.         const date = String(beijingTime.getUTCDate()).padStart(2, '0');
    69.         const hours = String(beijingTime.getUTCHours()).padStart(2, '0');
    70.         const minutes = String(beijingTime.getUTCMinutes()).padStart(2, '0');
    71.         const seconds = String(beijingTime.getUTCSeconds()).padStart(2, '0');

    72.         const weekdays = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
    73.         const weekday = weekdays[beijingTime.getUTCDay()];

    74.         timeDisplay.innerHTML = `
    75.             <div style="margin-bottom: 3px; font-size: 12px; opacity: 0.9;">北京时间</div>
    76.             <div style="font-size: 16px; margin-bottom: 2px;">${year}-${month}-${date}</div>
    77.             <div style="font-size: 18px; color: #4CAF50; margin-bottom: 3px;">${hours}:${minutes}:${seconds}</div>
    78.             <div style="font-size: 12px; opacity: 0.8;">${weekday}</div>
    79.         `;
    80.     }

    81.     document.body.appendChild(timeDisplay);
    82.     updateTime();
    83.     setInterval(updateTime, 1000);

    84.     let isDragging = false;
    85.     let dragOffset = { x: 0, y: 0 };

    86.     timeDisplay.addEventListener('mousedown', function(e) {
    87.         if (GM_getValue('timeLocked', false)) return;

    88.         isDragging = true;
    89.         dragOffset.x = e.clientX - timeDisplay.getBoundingClientRect().left;
    90.         dragOffset.y = e.clientY - timeDisplay.getBoundingClientRect().top;
    91.         timeDisplay.style.cursor = 'grabbing';
    92.         e.preventDefault();
    93.     });

    94.     document.addEventListener('mousemove', function(e) {
    95.         if (!isDragging || GM_getValue('timeLocked', false)) return;

    96.         const x = e.clientX - dragOffset.x;
    97.         const y = e.clientY - dragOffset.y;

    98.         const maxX = window.innerWidth - timeDisplay.offsetWidth;
    99.         const maxY = window.innerHeight - timeDisplay.offsetHeight;

    100.         const finalX = Math.max(0, Math.min(x, maxX));
    101.         const finalY = Math.max(0, Math.min(y, maxY));

    102.         timeDisplay.style.left = finalX + 'px';
    103.         timeDisplay.style.top = finalY + 'px';
    104.         timeDisplay.style.right = 'auto';

    105.         GM_setValue('timePosition', { top: finalY, right: window.innerWidth - finalX - timeDisplay.offsetWidth });
    106.     });

    107.     document.addEventListener('mouseup', function() {
    108.         if (isDragging) {
    109.             isDragging = false;
    110.             if (!GM_getValue('timeLocked', false)) {
    111.                 timeDisplay.style.cursor = 'move';
    112.             }
    113.         }
    114.     });

    115.     window.addEventListener('resize', function() {
    116.         const rect = timeDisplay.getBoundingClientRect();
    117.         if (rect.right > window.innerWidth || rect.bottom > window.innerHeight) {
    118.             const newX = Math.max(0, window.innerWidth - rect.width - 20);
    119.             const newY = Math.max(0, window.innerHeight - rect.height - 20);

    120.             timeDisplay.style.left = newX + 'px';
    121.             timeDisplay.style.top = newY + 'px';
    122.             timeDisplay.style.right = 'auto';

    123.             GM_setValue('timePosition', { top: newY, right: 20 });
    124.         }
    125.     });
    126. })();
    复制代码

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x

    评分

    参与人数 3血液 +9 追随 +3 堕落 +1 收起 理由
    kibody + 1
    呆到自然蠢 + 5 + 1 三连献上
    是阿行嘞 + 4 + 1 + 1 赞美

    查看全部评分

    回复

    使用道具 举报

    法师 · I

    雾港捞月鎏彩万幢法师I· 资深法师裸体克里斯都市:天际线2刀锋女王 - 归宿荣光的残像官复原职实现梦想传奇

      回复

      使用道具 举报

      森林羊男瑞雪兆丰年,生灵万物新荒野大镖客:救赎 II赛博朋克2077恶魔城牧羊人GM論壇勛章

        回复

        使用道具 举报

        『随时随地开启!』『随时随地开启!』小小舞台

          回复

          使用道具 举报

          纯真护剑㊕适当显灵无瑕的回忆

            回复

            使用道具 举报

            猫咪合唱团(夏日)業火死鬥帅气的本・比格十年一梦【夏日限定】夏日的泰凯斯永远的克叔炙热的格拉迪欧拉斯永浴爱河男巫之歌虚空之海的鲸

              回复

              使用道具 举报

              【新春限定】果体 隆【夏日限定】夏日的泰凯斯裸体克里斯卡洛斯·奥利维拉人到中年格拉迪欧拉斯尤利西斯炙热的格拉迪欧拉斯

                回复

                使用道具 举报

                我的天使GM吸血伯爵吃饱金币的Doge苏格兰圆脸胖鸡小小舞台守卫: 坚守眼位永浴爱河肉垫手套御医神兔『搓粉团珠』

                  回复

                  使用道具 举报

                  炉石与家猫咪合唱团(夏日)盈满心相元石法师I· 学识之章『召唤好运的角笛』雾港捞月鎏彩万幢男巫之歌女巫之路虚空之海的鲸

                    回复

                    使用道具 举报

                    抉择SCP-s-1889-第七页You Can Pet Blaidd达拉然Dante鸿蒙方舟葡萄精酿威猛尼特

                      回复

                      使用道具 举报

                      『狄文卡德的残羽』鎏彩万幢牧羊人桂花米糕

                        回复

                        使用道具 举报

                        万众瞩目金钱马车阿拉喵?神灯吃饱金币的Doge苏格兰圆脸胖鸡可爱毛团享受美食的小伯樱花树下的它眠眠茧

                          回复

                          使用道具 举报

                          龙神巴哈姆特巴哈姆特裸体克里斯羅素·托維【新春限定】果体 隆克里斯·埃文斯丹·雷诺斯杰夫‧莫罗

                            谢谢大佬分享 歪个楼 安卓党有更方便的功能 开发者模式里有时间悬浮窗功能 打开就好了 当然嫌麻烦或者找不到的也可以使用楼主的脚本
                            回复

                            使用道具 举报

                            法师I· 资深法师炽天使之拥被释放的灵魂雾港捞月

                              回复

                              使用道具 举报

                                回复

                                使用道具 举报

                                雾港捞月裸体克里斯我的冶金打火机先祖之魂夜魔护符

                                  虽然确实不会忘了时间了,但是网络繁忙网络异常在等着!还是谢谢楼主制作!
                                  回复

                                  使用道具 举报

                                  凛霜魔典『英勇赞美诗』暗蚀魔典五花八门版块

                                    回复

                                    使用道具 举报

                                    自定义男从Homunculus钢铁侠凯登‧阿兰科永远的克叔【夏日限定】夏日的泰凯斯裸体克里斯苏格兰圆脸胖鸡[Pro Max]极·龙の意生金蛋的鹅虚空之海的鲸

                                      回复

                                      使用道具 举报

                                      裸体克里斯鎏金魔典【新春限定】果体 隆圣甲虫秘典小镇的站台新神的赐福永远的守护者永远的克叔凯登‧阿兰科史莱姆牧场

                                        回复

                                        使用道具 举报

                                        【新春限定】果体 隆小镇的站台新神的赐福黄金树的恩惠生金蛋的鹅【圣诞限定】心心念念小雪人永远的克叔男巫之歌亚瑟‧摩根虚空之海的鲸

                                          XLK 发表于 2025-10-6 05:08:11 | 显示全部楼层 |取消关注该作者的回复
                                          回复

                                          使用道具 举报

                                          您需要登录后才可以回帖 登录 | 立即注册

                                          本版积分规则

                                          关闭

                                          站长公告上一条 /1 下一条

                                          文字版|手机版|小黑屋|GameMale

                                          GMT+8, 2026-8-8 04:53 , Processed in 0.128016 second(s), 148 queries , Redis On.

                                          Copyright © 2013-2026 GameMale

                                          All Rights Reserved.

                                          快速回复 返回列表