// 仮の変数にPower Automate Desktopから取得した文字列を設定
var searchText = "ここに検索文字列を入力";
// 検索文字列を含む<td>要素の左隣の<td>内の<a>タグをクリックする関数
function clickLinkInAdjacentLeftTd(searchText) {
const tds = document.querySelectorAll('td');
// 全ての<td>要素をループ
for (let i = 0; i < tds.length; i++) {
if (tds[i].textContent.includes(searchText) && i > 0) {
const previousTd = tds[i - 1]; // 左隣の<td>要素を取得
const link = previousTd.querySelector('a'); // 左隣の<td>内の最初の<a>要素を取得
if (link) {
link.click(); // <a>タグが存在すればクリック
break; // 最初に見つかった要素のみ操作
}
}
}
}
// 関数を呼び出す
clickLinkInAdjacentLeftTd(searchText);
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme