Greasy Fork

Greasy Fork is available in English.

RPC切换

方便地切换RPC主机地址

目前为 2025-04-28 提交的版本。查看 最新版本

// ==UserScript==
// @name         RPC切换
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  方便地切换RPC主机地址
// @author       jiemo
// @match        *://pan.quark.cn/*
// @grant        unsafeWindow
// @license MIT
// ==/UserScript==

(function() {
  'use strict';
  const rpcAddresses = [
      //填写你的多个rpc-domain
    'https://1.de',
    'https://2.de',
    'https://3.de'
  ];

  const rpcSwitcher = function(value) {
    unsafeWindow.base.setValue('setting_rpc_domain', value);
  };

  // 创建一个下拉选择框来切换RPC主机地址
  const select = document.createElement('select');
  select.className = 'ant-select-selection ant-select-selection--single';
  select.style.width = '150px';

  rpcAddresses.forEach((address) => {
    const option = document.createElement('option');
    option.value = address;
    option.text = address;
    select.appendChild(option);
  });

  select.onchange = function() {
    rpcSwitcher(this.value);
  };

  // 将下拉选择框放置在指定的按钮右侧
  const targetButton = document.querySelector('.ant-btn.btn-file.btn-create-folder');
  if (targetButton) {
    targetButton.parentNode.insertBefore(select, targetButton.nextSibling);
  }

  // 初始化下拉选择框的值
  const currentRpcAddress = unsafeWindow.base.getValue('setting_rpc_domain');
  select.value = currentRpcAddress;
})();