0

Citrix Web ポータルへのログインを自動化する Safari アプリ拡張機能を作成しています。挿入された JavaScript は、2 つのことを行う必要があります。最初に、送信する HTML フォームがあります (名前/パスワード付き)。これは問題なく動作し、クリックする必要がある HTML アンカーのある別のページに移動します。問題は、HTML アンカー リンクをプログラムでクリックできないことです。

// This is the `script.js` injected by my Safari App Extension

document.addEventListener("DOMContentLoaded", function(event) {


    if (document.URL.includes("IdentityFederationPortal")) {
        document.getElementById("UserId").value = "..." // my login
        document.getElementById("Password").value = "..." // my password
        document.getElementById("submit").click() // <- works correctly
    }

    // The `.click()` method above works just fine, I assume because it is used on a form button.


    if (document.URL.includes("TPDCWeb")) {

        var loginLink = document.querySelector("#plugin-assistance-download > div > div > div > div.footer > a.pluginassistant-skiplink.web-screen-link._ctxstxt_SkipToLogon._ctxsattr_title_SkipToLogonTip");

        console.log(loginLink) // console shows loginLink is assigned the correct HTML anchor

        loginLink.click() // does not work!
    }
});

ノート:

  1. プログラムでクリックする必要があるアンカー リンクの実際の HTML は次のとおりです。<a class="pluginassistant-skiplink web-screen-link _ctxstxt_SkipToLogon _ctxsattr_title_SkipToLogonTip" href="#" title="Click here to skip to log on">Log on</a>通常のユーザーがそのリンクをクリックしたときに何が起こっているかを理解できるほど、Web プログラミングに精通していません。プロパティがありNULL onClickます)。

  2. ここで jQuery が役立つ可能性があることを示唆する参照が散在しているのを見てきましたが、jQuery を Safari App Extension スクリプトに挿入する方法もわかりません。jQueryを使用しようとすると、これまでの試行でCan't find variable $エラーが発生しました。

4

1 に答える 1