Auto Click SSO Continue

在 SSO 认证页自动点击 Continue 按钮

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

Advertisement:

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

Advertisement:

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Auto Click SSO Continue
// @namespace    local-auto-sso-continue
// @version      1.0
// @description  在 SSO 认证页自动点击 Continue 按钮
// @match        https://github.com/*
// @match        https://*.okta.com/*
// @match        https://*.pingidentity.com/*
// @match        https://*/sso/*
// @match        https://*/saml/*
// @run-at       document-idle
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
  'use strict';

  // 关键词:按钮文字匹配,避免依赖具体 class(SSO 模板可能变化)
  const BUTTON_TEXT = 'continue';

  function findContinueButton() {
    const candidates = document.querySelectorAll('button, a, input[type="submit"]');
    for (const el of candidates) {
      const text = (el.innerText || el.value || '').trim().toLowerCase();
      if (text === BUTTON_TEXT) {
        return el;
      }
    }
    return null;
  }

  function tryClick() {
    const btn = findContinueButton();
    if (btn && !btn.disabled) {
      btn.click();
      return true;
    }
    return false;
  }

  // 页面加载后立即尝试一次
  if (tryClick()) return;

  // 用 MutationObserver 监听 SSO 页面动态渲染(很多 SSO 页面是 SPA,按钮可能延迟出现)
  const observer = new MutationObserver(() => {
    if (tryClick()) {
      observer.disconnect();
    }
  });

  observer.observe(document.body, { childList: true, subtree: true });

  // 兜底:10秒后停止监听,避免无限占用资源
  setTimeout(() => observer.disconnect(), 10000);
})();