Greasy Fork is available in English.

NitterCorpusStorage

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

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.greasyfork.org/scripts/579922/1835585/NitterCorpusStorage.js

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

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