私はHTMLタグを選択し、それにいくつかのことをするスクリプト(拡張機能)に取り組んでいます。ただし、このHTMLタグは、特定の時間にページ上に動的にロードされ、読み込まれるとすぐに検出したいと考えています。現在、私はwhileループ(未定義のチェック)でhtmlページをポーリングしていますが、ページに多くの遅延があります。回避策はありますか?クロム拡張ポーリングhtmlの遅れページ
$(document).ready(function() {
// some code
var sizesList=document.getElementsByClassName("exp-pdp-size-dropdown-container nsg-form--drop-down--option-container selectBox-options nsg-form--drop-down exp-pdp-size-dropdown exp-pdp-dropdown two-column-dropdown selectBox-dropdown-menu")[0];
while(typeof(sizesList) == 'undefined') {
setTimeout(function() {}, 700)
sizesList=document.getElementsByClassName("exp-pdp-size-dropdown-container nsg-form--drop-down--option-container selectBox-options nsg-form--drop-down exp-pdp-size-dropdown exp-pdp-dropdown two-column-dropdown selectBox-dropdown-menu")[0];
}
// some more code
}
私はthisウェブページでテストしています。
を。その要素が現れるまで、setTimeoutを呼び出す関数を持つ方がいいかもしれません。 – Shadow