GameMale
登陆 / 注册 搜索

USERCENTER

SEARCHSITE

搜索

查看: 1782|回复: 58
收起左侧

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

  [复制链接] |关注本帖

GM活动员

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 赞美

    查看全部评分

    回复

    使用道具 举报

    鎏彩万幢传奇都市:天际线2刀锋女王 - 归宿丹妮莉丝·坦格利安官复原职实现梦想丹雀衔五穗,人间始丰登Zootopia最终幻想XVI

      娱乐伙伴琴键猴 发表于 2025-10-6 00:21:49 | 显示全部楼层 <
      回复

      使用道具 举报

      赛博朋克2077恶魔城牧羊人GM論壇初心者畢業證書红龙幼崽山猫图腾眼镜蛇图腾

        薯条 发表于 2025-10-6 00:25:05 | 显示全部楼层 <
        回复

        使用道具 举报

        漂洋小船冒险用指南针破损的旧书人鱼之泪雪王的心脏苏格兰圆脸胖鸡[Pro Max]丛林的鸟飞走了不曾寄出的信件幽灵竹筒『随时随地开启!』

          凯诺斯 发表于 2025-10-6 00:26:40 | 显示全部楼层 <
          回复

          使用道具 举报

          『逆境中的幸运女神』无瑕的回忆

            安氏贵人鸟 发表于 2025-10-6 00:28:45 | 显示全部楼层 <
            回复

            使用道具 举报

            史莱哲林肉乖乖旧日支配者—克苏鲁業火死鬥魔法不朽·传奇不熄十年一梦炙热的格拉迪欧拉斯卡洛斯·奥利维拉男巫之歌永浴爱河

              Burry 发表于 2025-10-6 00:29:30 | 显示全部楼层 <
              回复

              使用道具 举报

              雄躯的昇格裸体克里斯卡洛斯·奥利维拉人到中年格拉迪欧拉斯尤利西斯炙热的格拉迪欧拉斯

                liu_chris 发表于 2025-10-6 00:32:13 | 显示全部楼层 <
                回复

                使用道具 举报

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

                  毛茸茸兽兽 发表于 2025-10-6 00:34:13 | 显示全部楼层 <
                  回复

                  使用道具 举报

                  弗雷迪玩偶发条八音盒桂花米糕鎏彩万幢女巫之路虚空之海的鲸【新春限定】果体 隆『召唤好运的角笛』永远的克叔業火死鬥

                    娱乐法师火布偶 发表于 2025-10-6 00:50:26 | 显示全部楼层 <
                    回复

                    使用道具 举报

                    20x43 隐形➁抉择20x43 隐形➀You Can Pet Blaidd达拉然SCP-s-1889-第五页Dante

                      crabee 发表于 2025-10-6 00:52:27 | 显示全部楼层 <
                      回复

                      使用道具 举报

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

                        3049973969 发表于 2025-10-6 01:12:32 | 显示全部楼层 <
                        回复

                        使用道具 举报

                        万众瞩目金钱马车苏格兰圆脸胖鸡可爱毛团享受美食的小伯夏日柯基眠眠茧百万核爆

                          Brine 发表于 2025-10-6 01:37:54 | 显示全部楼层 <
                          回复

                          使用道具 举报

                          发条八音盒弗雷迪玩偶巴哈姆特龙神巴哈姆特守护者三角头丹·雷诺斯远行杰夫‧莫罗克里斯·埃文斯

                            翳云之上 发表于 2025-10-6 01:46:42 | 显示全部楼层 <
                            谢谢大佬分享 歪个楼 安卓党有更方便的功能 开发者模式里有时间悬浮窗功能 打开就好了 当然嫌麻烦或者找不到的也可以使用楼主的脚本
                            回复

                            使用道具 举报

                            琉璃玉坠男用贞操带圣诞寻铃漂洋小船破损的旧书冒险用指南针秘密空瓶苏格兰圆脸胖鸡[Pro Max]暮光独角兽幼崽

                              reober3 发表于 2025-10-6 02:00:01 | 显示全部楼层 <
                              回复

                              使用道具 举报

                              发条八音盒弗雷迪玩偶极速追杀瑞雪兆丰年,生灵万物新风雪之家黄色就是俏皮牧羊人

                                xinhen0305 发表于 2025-10-6 02:04:18 | 显示全部楼层 <
                                回复

                                使用道具 举报

                                日荒戒指霍格沃兹特快列车驯化黑龙幼崽铁牛男用贞操带DocGM論壇進階勛章【新手友好】昆進

                                  Dust# 发表于 2025-10-6 02:31:23 | 显示全部楼层 <
                                  虽然确实不会忘了时间了,但是网络繁忙网络异常在等着!还是谢谢楼主制作!
                                  回复

                                  使用道具 举报

                                  雷霆晶球水泡术史莱哲林收到情书幸运女神的微笑呆猫『钟楼日暮』『逆境中的幸运女神』『南瓜拿铁』『搓粉团珠』

                                    是阿行嘞 发表于 2025-10-6 02:36:38 | 显示全部楼层 <
                                    回复

                                    使用道具 举报

                                    自定义男从Homunculus诺克提斯·路西斯·伽拉姆Forever Titanic钢铁侠永远的克叔【夏日限定】夏日的泰凯斯极·龙の意苏格兰圆脸胖鸡[Pro Max]虚空之海的鲸史莱姆牧场

                                      轮回2L 发表于 2025-10-6 04:16:58 | 显示全部楼层 <
                                      回复

                                      使用道具 举报

                                      咆哮虎的冠军之路You Can Pet Blaidd業火死鬥炙热的格拉迪欧拉斯裸体克里斯圣甲虫秘典永远的克叔【新春限定】果体 隆新神的赐福凯登‧阿兰科

                                        星之子 发表于 2025-10-6 04:30:33 | 显示全部楼层 <
                                        回复

                                        使用道具 举报

                                        一国之主黄金树的恩惠生金蛋的鹅【圣诞限定】心心念念小雪人新神的赐福永远的克叔亚瑟‧摩根虚空之海的鲸自由Forever Titanic

                                          XLK 发表于 2025-10-6 05:08:11 | 显示全部楼层 <
                                          回复

                                          使用道具 举报

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

                                          本版积分规则

                                          关闭

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

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

                                          GMT+8, 2025-12-6 07:02 , Processed in 0.160077 second(s), 147 queries , Redis On.

                                          Copyright © 2013-2025 GameMale

                                          All Rights Reserved.

                                          快速回复 返回列表