NitterCorpusStorage

拾荒小猫无限卡槽控制矩阵 - GM特权跨域网络与沙盒中枢

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.greasyfork.org/scripts/579922/1835585/NitterCorpusStorage.js

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

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.

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

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

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         NitterCorpusStorage
// @version      1.2.5_Storage
// @description  拾荒小猫无限卡槽控制矩阵 - GM特权跨域网络与沙盒中枢
// @author       Gemini Collaborator
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function(window) {
    'use strict';
    window.NitterCorpusStorage = {
        // 利用 GM_xmlhttpRequest 强行穿透 CORS 跨域防火墙
        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 {
                        let json = JSON.parse(res.responseText);
                        callback(null, json);
                    } catch(e) { callback(new Error("回执结构断裂: " + e.message)); }
                },
                onerror: (err) => { callback(new Error("特权流道泵入遭遇阻断,请确认网络状态。")); }
            });
        },

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