Skip to content
This repository was archived by the owner on Aug 4, 2026. It is now read-only.

feat: add iframe target to recorded actions - #8

Merged
Xia Dong (xiadongdev) merged 2 commits into
developfrom
store-target
Jun 2, 2026
Merged

feat: add iframe target to recorded actions#8
Xia Dong (xiadongdev) merged 2 commits into
developfrom
store-target

Conversation

@xiadongdev

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds iframe-awareness to the action recorder so recorded actions can be replayed/generated against elements inside iframes (rather than always targeting the top document).

Changes:

  • Inject the recorder content script into all frames and capture the sender frameId for recorded actions.
  • Resolve an iframe CSS selector from a frameId (via chrome.webNavigation) and attach it to recorded actions (iframeSelector), then use it during script/preaction generation.
  • Show the recording badge only in the top frame; add webNavigation permission.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
background.js Injects recorder into all frames; resolves iframeSelector for frame messages using webNavigation and uses it in recorded actions.
manifest.json Adds the webNavigation permission required to enumerate frames.
recorder.js Ensures the recording badge only renders in the top frame when injected into all frames.
script_generator.js Updates script/preaction generation to scope selectors/actions to an iframe document/target when iframeSelector is present.
Comments suppressed due to low confidence (1)

script_generator.js:1873

  • convertRecordingToPreactions adds target for click/type/select, but setChecked still emits a script without any target. Checkbox/radio recordings inside iframes will therefore lose iframe targeting when saved as preactions.
      preactions.push(preaction);
      continue;
    }

    if (action.type === "setChecked") {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread background.js
Comment on lines +3229 to +3233
const frameId = sender.frameId;
if (frameId && frameId !== 0) {
resolveIframeSelector(tabId, frameId).then((iframeSelector) => {
rec.actions.push({ ...message.payload, iframeSelector: iframeSelector ?? null });
});
Comment thread background.js Outdated
Comment thread background.js
Comment thread script_generator.js

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

background.js:3238

  • stop-recording now runs the cleanup in all frames and sets window.__vpRecorderInstalled = false. Since recorder.js does not remove its event listeners, restarting recording in the same tab/frame can install duplicate listeners and produce duplicated recorded actions. This was already risky in the top frame; with allFrames: true it can multiply across iframes.
        await chrome.scripting.executeScript({
          target: { tabId, allFrames: true },
          func: () => {
            document.getElementById("__vp-recorder-badge")?.remove();
            window.__vpRecorderInstalled = false;
          },

Comment thread script_generator.js
Comment on lines +1867 to +1869
const preaction = { select: { field, value: action.value } };
if (target) preaction.target = target;
preactions.push(preaction);
Comment thread background.js
Comment on lines +2681 to +2687
const parentFrameId = frame.parentFrameId;
if (parentFrameId == null || parentFrameId < 0) return null;
const frameUrl = frame.url;

const results = await chrome.scripting.executeScript({
target: { tabId, frameIds: [parentFrameId] },
func: (url) => {
@xiadongdev
Xia Dong (xiadongdev) merged commit ab60e4d into develop Jun 2, 2026
2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants