NitterCorpusEnv

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

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/579924/1835587/NitterCorpusEnv.js

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==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);