Create new tab, then append script into it (javascript)

Basically, I want to create a new tab, and then append a script tag into the tab in javascript. Only thing is though… It won’t work even though it should (coding logic). Here is the javascript for the site:

var win = window.open('https://google.com');
var script = document.createElement('script');
script.textContent = `
var script = document.createElement('script');
script.setAttribute("type", "text/javascript");
script.setAttribute("src", "https://inspect-pro-source.daxcodes.repl.co/script.js");
document.head.appendChild(script);
`;
win.document.head.appendChild(script);

Here is the replit site in general: testscript - HTML, CSS, JS Repl - Replit

Here is what it should do on the google site that it opened (what i want):
Screenshot 2022-09-23 190259

Here is what it is doing on the google site that it opened (dont want):

Screenshot 2022-09-23 190404

If anybody can help, that will be greatly appreciated!

Thanks,
@DaxCodes

1 Like

I’m not 100% sure, but I don’t think this will work, the reason being, if you could do this security would be a major issue, you could easily inject JavaScript into other webpages.
Yep, I’m pretty sure I’m right: Stackoverflow - How can I access the dom tree of child window?

1 Like

oh darn it, my school blocked bookmarklets the other day, so i was hoping for an alternative. Do you have any suggestions (inspect element and page view is also blocked)

1 Like

What are you trying to do? Are you trying to get around the block and see the developer console?

Just some basic things you can try: if the school blocks things via wifi, you can connect to a mobile hotspot to get around it. My school also blocks inspect element, but only in my school account, so if I sign in to Google with a personal account I can still open the developer console.

1 Like
  1. I don’t have a mobile hotspot.
  2. Chromebooks wont work.

at least they didnt block it for the actual windows computers.

I wish they didnt block bookmarklets

1 Like

pretty much yeah. but bookmarklets are blocked + inspect element

1 Like