OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Browser console script open new window, read final url, close window

  • Thread starter Thread starter user2183336
  • Start date Start date
U

user2183336

Guest
I want to discover a long list of urls final redirect locations. I want to do this with a console script and can't change any browser permissions or install add-ons because I only have access to a public computer.

An example:

Code:
function sleep(ms) {
 return new Promise(resolve => setTimeout(resolve, ms));
}

// doesn't work
const w = window.open('http://www.example.com', '_blank');
await sleep(3000); // wait for everything to load
const finalUrl = w.location.href; // chrome blocks this?
w.close(); // chrome does nothing with this command

Chrome doesn't want me to do this. The w.location.href command is blocked with an error:

Code:
Uncaught DOMException: Failed to read a named property 'href' from 'Location': Blocked a frame with origin "chrome://new-tab-page" from accessing a cross-origin frame.

Woah there guy. Then the w.close() command does nothing.

Can you?

<p>I want to discover a long list of urls final redirect locations. I want to do this with a console script and can't change any browser permissions or install add-ons because I only have access to a public computer.</p>
<p>An example:</p>
<pre><code>function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

// doesn't work
const w = window.open('http://www.example.com', '_blank');
await sleep(3000); // wait for everything to load
const finalUrl = w.location.href; // chrome blocks this?
w.close(); // chrome does nothing with this command
</code></pre>
<p>Chrome doesn't want me to do this. The <code>w.location.href</code> command is blocked with an error:</p>
<pre><code>Uncaught DOMException: Failed to read a named property 'href' from 'Location': Blocked a frame with origin "chrome://new-tab-page" from accessing a cross-origin frame.
</code></pre>
<p>Woah there guy. Then the <code>w.close()</code> command does nothing.</p>
<p>Can you?</p>
 

Latest posts

Z
Replies
0
Views
1
zuegelwagen
Z
Top