NitterCorpusNet

拾荒小猫控制矩阵 - GM特权网络、TextDB分布式网络流与重度格式拼装机

Dieses Skript sollte nicht direkt installiert werden. Es handelt sich hier um eine Bibliothek für andere Skripte, welche über folgenden Befehl in den Metadaten eines Skriptes eingebunden wird // @require https://update.greatest.deepsurf.us/scripts/579925/1835588/NitterCorpusNet.js

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         NitterCorpusNet
// @version      1.2.6_Net
// @description  拾荒小猫控制矩阵 - GM特权网络、TextDB分布式网络流与重度格式拼装机
// @author       Gemini Collaborator
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function(window) {
    'use strict';

    window.NitterNet = {
        async cloudUpdate(url, key, value, action, callback) {
            let dataPayload = `key=${encodeURIComponent(key)}&value=`;
            if (action !== 'delete') dataPayload += encodeURIComponent(value);
            GM_xmlhttpRequest({
                method: 'POST',
                url: action === 'delete' ? `${url}?key=${key}&value=` : url,
                headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
                data: action === 'delete' ? '' : dataPayload,
                onload: (res) => {
                    try { callback(null, JSON.parse(res.responseText)); } catch(e) { callback(new Error("回执结构断裂: " + e.message)); }
                },
                onerror: () => callback(new Error("特权泵入流遭遇阻断。"))
            });
        },

        async remoteFetch(url, callback) {
            GM_xmlhttpRequest({
                method: 'GET', url: url,
                onload: (res) => callback(null, res.responseText),
                onerror: () => callback(new Error("远端同步流路径死锁"))
            });
        },

        buildPromptText(envStore, username, host) {
            const cfg = envStore.config;
            const processed = envStore.tweets.map(rawBlock => {
                let prefix = rawBlock.match(/\[METAPREFIX\]([\s\S]*?)\[\/METAPREFIX\]/)?.[1] || '';
                let hot = rawBlock.match(/\[HOTMETRIC\]([\s\S]*?)\[\/HOTMETRIC\]/)?.[1] || '';
                let base = rawBlock.match(/\[BASETEXT\]([\s\S]*?)\[\/BASETEXT\]/)?.[1] || '';
                let mediaLines = [];
                rawBlock.split('\n').forEach(line => {
                    if (line.startsWith('__IMG__') && cfg.img) mediaLines.push(line.replace('__IMG__', ''));
                    if (line.startsWith('__VID__') && cfg.video) mediaLines.push(line.replace('__VID__', ''));
                });
                let finalPrefix = cfg.stamp ? prefix : (prefix.includes('[🔄 转推自:') ? (prefix.match(/\[🔄 转推自:.*?\]/)?.[0] || '') : '');
                let blockParts = [];
                if (finalPrefix.trim()) blockParts.push(finalPrefix.trim());
                if (cfg.hot && hot.trim()) blockParts.push(hot.trim());
                if (base.trim()) blockParts.push(base.trim());
                if (mediaLines.length > 0) blockParts.push(mediaLines.join('\n'));
                return blockParts.join('\n').trim();
            }).filter(t => t && t.trim().length > 0);

            return `${cfg.customPrompt}\n\n以下是目标用户的真实账号元数据与推文语料库(共 ${processed.length} 条):\n--------------------------------------------------\n【原始主页元数据纯文本】\n${envStore.metaText || '未抓取到描述'}\n\n【清洗过滤后的大批量推文语料库】\n${processed.join('\n---\n')}\n--------------------------------------------------`;
        },

        generateGfCode(envStore) {
            let lines = [ "// ==UserScript==", "// @name         拾荒小猫_云端扩展组件", `// @version      ${Date.now()}`, "// ==/UserScript==", "", "window.CloudPrompts = {" ];
            envStore.slots.forEach((s, idx) => {
                const key = s.name.replace(/[^\w\u4e00-\u9fa5]/g, '') || `slot_${idx}`;
                const formatter = s.content.split('\n').map(line => `        ${JSON.stringify(line)}`).join(',\n');
                lines.push(`    ${JSON.stringify(key)}: [\n${formatter}\n    ].join('\\n')${idx === envStore.slots.length - 1 ? '' : ','}`);
            });
            lines.push("};"); return lines.join('\n');
        }
    };
})(window);