After successfully solving the issue, I have documented the solution here for anyone who may find it useful.
I utilized an iframe
to embed my component or page into the loaded web page.
Initially, I defined a new route named test
in the routes.js file:
{
name: "test",
path: "/test",
component: () => import("pages/test.vue"),
},
Next, I created an iframe and loaded the specific route in the content-script.js as follows:
function createIframe() {
const iframe = document.createElement("iframe");
iframe.width = "220px";
iframe.height = "220px";
Object.assign(iframe.style, {
position: "fixed",
border: "none",
zIndex: "10000",
});
// Load the specified page
iframe.src = chrome.runtime.getURL("www/index.html#test");
return iframe;
}
You can customize the dimensions and other attributes of your iframe as needed.
Then, you can insert it as an element anywhere using:
document.body.prepend(createIframe());
And that's it! The solution is implemented successfully. :)