将浏览器时间改成ip时间

将浏览器时间改成ip时间cccc

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// <code>@name</code>  将浏览器时间改成ip时间
// @name  将浏览器时间改成ip时间
// @match https://ip8.com
// <code>@description</code> 将浏览器时间改成ip时间
// @description 将浏览器时间改成ip时间cccc
// @version 0.0.1.20250227060029
// @namespace https://greasyfork.org/users/715846
// ==/UserScript==

// 从页面中提取 IP 时间(需根据实际页面结构修改选择器)
function extractIPTime() {
  const timeElement = document.querySelector('table td[data-test="IP Time-ip-details"]'); // 假设页面中显示时间的元素 ID
  return timeElement?.textContent?.trim();
}

// 覆盖 Date 对象以模拟时间
function overrideDate(ipTime) {
  const originalDate = Date;
  const targetTime = new Date(ipTime).getTime();

  // 重写 Date 构造函数
  window.Date = class extends Date {
    constructor(...args) {
      if (args.length === 0) {
        return new originalDate(targetTime); // 返回模拟时间
      }
      return new originalDate(...args);
    }
    static now() {
      return targetTime; // 覆盖 Date.now()
    }
  };
}

// 主逻辑
(async () => {
  const ipTime = extractIPTime();
  if (!ipTime) return;

  const browserTime = new Date();
  const ipTimeDate = new Date(ipTime);

  // 比对时间(允许误差 1 秒)
  if (Math.abs(ipTimeDate - browserTime) > 1000) {
    overrideDate(ipTime);
    console.log('已模拟浏览器时间为 IP 时间:', ipTime);
  }
})();