Can you embed your own js script in iframe?

I want to inject a piece of my own js, when loading an iframe third-party web page to provide a method that can be accessed within the iframe. Can it be realized? -sharp-sharp-sharp problem description


is difficult to implement. If it is a cross-domain page that is basically not implemented by relying on the front end

if you want to inject code into someone else's site to do something, the easiest way for me to do it is to write a chrome plug-in, which is my current method of extracting data across sites

.

Cross-domain seems to be impossible


provides a method that can be accessed within the iframe?

you can operate third-party web pages, so why not? it's like quoting jq on cdn on your web page.
just give him your js src access address (ps: is not cross-domain or how can you use the jq of other people's servers)


it won't work if you don't have control over third-party pages


make an interface / foo receive two fields in the same domain, one is the address to be forwarded and the other is the content to be injected
iframe always fill in this interface
pseudo code is as follows

<iframe src="/foo?url=http://baz.bar.com/x/y&inject=function sayHi(){console.log('hi')}" />

background pseudo code

const express = require("express");
const app = express();
app.get("/foo",async (req,res)=>{
    const {url,inject} = req.params;
    // getHttp
    const data = await getHttp(url);
    // 
    res.end(parseAndInSert(data,inject));
});
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea8c94-1efa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea8c94-1efa.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?