NitterCorpusEnv

拾荒小猫控制矩阵 - 基础环境、卡槽状态与本地沙箱固化中枢

Ten skrypt nie powinien być instalowany bezpośrednio. Jest to biblioteka dla innych skyptów do włączenia dyrektywą meta // @require https://update.greatest.deepsurf.us/scripts/579924/1835587/NitterCorpusEnv.js

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         NitterCorpusEnv
// @version      1.2.6_Env
// @description  拾荒小猫控制矩阵 - 基础环境、卡槽状态与本地沙箱固化中枢
// @author       Gemini Collaborator
// @grant        none
// ==/UserScript==

(function(window) {
    'use strict';

    window.NitterEnv = {
        DB_KEY: '',
        HISTORY_KEY: 'rp_asset_history_pool',
        localStore: null,
        assetHistory: [],
        snapshottedBackup: null,
        defaultSlots: [
            { id: 'slot_1', name: '🎭 赛博拾荒者', content: '你是一个专业的推文分析师...' },
            { id: 'slot_2', name: '🎭 语料解构师', content: '提取并精炼以下推文的技术内核...' },
            { id: 'slot_3', name: '🎭 仿生复刻机', content: '克隆以下目标用户的发帖逻辑与语气...' }
        ],

        setup(host, username, metaText, tweets) {
            this.DB_KEY = `rp_corpus_${host}_${username}`;
            let rawStore = localStorage.getItem(this.DB_KEY);
            
            if (!rawStore) {
                this.localStore = {
                    currentPage: 1, lastUrl: "", tweets: [], metaText: metaText, activeSlotId: 'slot_1',
                    slots: JSON.parse(JSON.stringify(this.defaultSlots)),
                    config: { img: true, video: true, stamp: true, hot: true, level: 2, customPrompt: '你是一个专业的推文分析师...' }
                };
            } else {
                this.localStore = JSON.parse(rawStore);
                if (!this.localStore.slots || this.localStore.slots.length === 0) this.localStore.slots = JSON.parse(JSON.stringify(this.defaultSlots));
                if (!this.localStore.config) this.localStore.config = { img: true, video: true, stamp: true, hot: true, level: 2, customPrompt: this.localStore.slots[0].content };
            }

            tweets.forEach(t => {
                let existIndex = this.localStore.tweets.findIndex(old => old.includes(`[BASETEXT]${t.baseText}[/BASETEXT]`) || old.includes(t.baseText));
                if (existIndex !== -1) {
                    let oldBlock = this.localStore.tweets[existIndex];
                    if ((oldBlock.includes('💬评论: 0 | 🔄转推: 0') || !oldBlock.includes('[HOTMETRIC]')) && (t.replyCount !== "0" || t.retweetCount !== "0")) {
                        this.localStore.tweets[existIndex] = t.rawContentBlock;
                    }
                } else { this.localStore.tweets.push(t.rawContentBlock); }
            });
            
            this.localStore.metaText = metaText || this.localStore.metaText;
            this.save();

            try { this.assetHistory = JSON.parse(localStorage.getItem(this.HISTORY_KEY)) || []; } catch(e) { this.assetHistory = []; }
        },

        save() {
            localStorage.setItem(this.DB_KEY, JSON.stringify(this.localStore));
        },

        showToast(title, desc, isErr = false) {
            const container = document.getElementById('rp-toast-container');
            if (!container) return;
            const toast = document.createElement('div');
            toast.className = 'rp-toast';
            if (isErr) toast.style.borderLeftColor = '#f38ba8';
            toast.innerHTML = `<div style="font-weight:bold;margin-bottom:2px;">${title}</div><div style="color:#a6adc8;font-size:10px;">${desc}</div>`;
            container.appendChild(toast);
            setTimeout(() => toast.classList.add('show'), 50);
            setTimeout(() => { toast.classList.remove('show'); setTimeout(() => toast.remove(), 300); }, 3500);
        }
    };
})(window);