所有していないが改善したい Web アプリケーションをハッキングしようとしています。
同じドメインの iframe の DOM の要素の前に HTML を追加したいと思います。コンソールからのサンプルを次に示します。
jQ(".x-panel-body.x-panel-body-noheader").find("iframe").contents().find("body").find("#WorkspaceFrame").find(".x-panel-tbar.x-panel-tbar-noheader").find(".x-toolbar-right").find(".x-toolbar-right-ct").find("table");
[
<table cellspacing="0">…</table>,
<table id="ext-comp-1046" cellspacing="0" class="x-btn x-btn-text-icon" style="width: auto;">…</table>,
<table cellspacing="0">…</table>,
<table cellspacing="0">…</table>,
<table id="ext-comp-1067" cellspacing="0" class="x-btn x-btn-text-icon " style="width: auto;">…</table>,
<table id="ext-comp-1068" cellspacing="0" class="x-btn x-btn-text-icon " style="width: auto;">…</table>,
<table id="ext-comp-1069" cellspacing="0" class="x-btn x-btn-text-icon" style="width: auto;">…</table>,
<table cellspacing="0">…</table>,
<table cellspacing="0">…</table>,
<table id="ext-comp-1253" cellspacing="0" class="x-btn x-btn-text-icon x-item-disabled" style="width: auto;">…</table>,
<table id="ext-comp-1254" cellspacing="0" class="x-btn x-btn-text-icon" style="width: auto;">…</table>,
<table cellspacing="0">…</table>,
<table cellspacing="0">…</table>,
<table id="ext-comp-1760" cellspacing="0" class="x-btn x-btn-text-icon" style="width: auto;">…</table>,
<table cellspacing="0">…</table>
]
jQ
私のjQueryの名前です(私は使用できません$
)。
したがって、基本的にはコンソールから機能しsaveButton
、配列が含まれています。これが私のスクリプトです:
saveButton=jQ(".x-panel-body.x-panel-body-noheader").find("iframe").contents().find("body").find("#WorkspaceFrame").find(".x-panel-tbar.x-panel-tbar-noheader").find(".x-toolbar-right").find(".x-toolbar-right-ct").find("table");
console.log(saveButton);
jQ.each(saveButton, new function(i,v) { console.log("#"+i+": "+v); });
コンソール出力は次のとおりです。
[prevObject: b.fn.b.init[0], context: document, selector: "body #WorkspaceFrame .x-panel-tbar.x-panel-tbar-noheader .x-toolbar-right .x-toolbar-right-ct table", jquery: "1.9.1", constructor: function…]
#undefined: undefined
saveButton
オブジェクトもそうですが、配列ではありません。これは、failed によって確認されjQ.each
ます。
テーブルの 1 つ (常に 3 番目) を取り、コールしたいと思い.before('<p>something</p>')
ます。試してみsaveButton[2].before('<p>HI</p>')
ましたが、うまくいきません。
Zoltanの回答のヒントの後の新しい試みは次のとおりです。
jQ(".x-panel-body.x-panel-body-noheader").find("iframe").contents().find("body").find("#WorkspaceFrame").find(".x-panel-tbar.x-panel-tbar-noheader").find(".x-toolbar-right").find(".x-toolbar-right-ct").find("table").eq(8).find(">:first-child").find(">:first-child").find(">:first-child").before('<td class="x-toolbar-cell"><button>Test</button></td>');
コンソールにこれを適切に入力すると、必要な場所にボタンが追加されますが、JS コードの同じ行が機能しません。何を与える?