朱雀大模型 / BadStudent 试用次数重置器

通过随机化指定网站 localStorage 中的特定键值(如 'fp', 'deviceId'),重置使用次数限制。

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         朱雀大模型 / BadStudent 试用次数重置器
// @name:en      Zhuque AI Assistant / BadStudent Trial Count Resetter
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  通过随机化指定网站 localStorage 中的特定键值(如 'fp', 'deviceId'),重置使用次数限制。
// @description:en Resets usage limits for specified websites by randomizing specific keys (e.g., 'fp', 'deviceId') in localStorage.
// @author       Positionzer0
// @match        https://matrix.tencent.com/*
// @match        https://www.badstudent.ai/*
// @grant        none
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // --- 常量定义 ---
    const HEX_CHARACTERS = '0123456789abcdef';

    // --- 辅助函数 ---

    /**
     * 生成一个指定长度的随机十六进制字符串。
     * @param {number} length - 目标字符串的长度。
     * @returns {string} 生成的随机十六进制字符串。
     */
    function generateRandomHexString(length) {
        let result = '';
        for (let i = 0; i < length; i++) {
            const randomIndex = Math.floor(Math.random() * HEX_CHARACTERS.length);
            result += HEX_CHARACTERS.charAt(randomIndex);
        }
        return result;
    }

    /**
     * 生成一个 UUID v4 格式的字符串。
     * 格式: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
     * @returns {string} 生成的 UUID v4 字符串。
     */
    function generateUUIDv4() {
        return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
            const r = Math.random() * 16 | 0;
            const v = c === 'x' ? r : (r & 0x3 | 0x8); // 'y' 必须是 8, 9, a, or b
            return v.toString(16);
        });
    }

    /**
     * 在 localStorage 中设置新的值。
     * @param {string} key - localStorage 中的键名。
     * @param {string} value - 要设置的新值。
     * @param {string} siteName - 网站名称,用于日志记录。
     */
    function setNewLocalStorageValue(key, value, siteName) {
        try {
            localStorage.setItem(key, value);
            // console.log(`[${siteName} Reset Script] New value for '${key}': ${value}`);
        } catch (error) {
            console.error(`[${siteName} Reset Script] Error setting new value for '${key}' in localStorage:`, error);
        }
    }

    // --- 核心逻辑 ---

    /**
     * 根据当前网站应用相应的重置逻辑。
     */
    function applyResetLogic() {
        const hostname = window.location.hostname;

        if (hostname === 'matrix.tencent.com') {
            const FINGERPRINT_KEY = 'fp';
            const FINGERPRINT_LENGTH = 32;
            const newFingerprintValue = generateRandomHexString(FINGERPRINT_LENGTH);
            setNewLocalStorageValue(FINGERPRINT_KEY, newFingerprintValue, 'Zhuque');
        } else if (hostname === 'www.badstudent.ai') {
            const DEVICE_ID_KEY = 'deviceId';
            const newDeviceId = generateUUIDv4();
            setNewLocalStorageValue(DEVICE_ID_KEY, newDeviceId, 'BadStudentAI');
        }
    }

    // --- 执行 ---
    // 立即执行重置逻辑
    applyResetLogic();

})();