NitterCorpusEnv

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

Αυτός ο κώδικας δεν πρέπει να εγκατασταθεί άμεσα. Είναι μια βιβλιοθήκη για άλλους κώδικες που περιλαμβάνεται μέσω της οδηγίας meta // @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 για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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