crashwap
crashwap

Reputation: 3068

Change a pop-up window's title using a Tampermonkey script?

Is there a way to use Tampermonkey to change the window title for a pop-up (child?) window? (This is for a streaming audio player)

Usually, we would use document.title to change the browser page/tab title for a webpage, but in this case it doesn't work. I believe that is because it is a pop-up spawned by the main webpage.

Is there a way to accomplish this via Tampermonkey.

This is the site with the pop-up I wish to modify. Click the "Listen Now" red button at top right and the pop-up will. I wish to change the title for that pop-up window.


References I tried/used:

Upvotes: 5

Views: 1807

Answers (2)

Ian.V
Ian.V

Reputation: 375

You can open a new link to your own site with an iframe of your targeted site and change the title of your own site.

example normal html:

<html>
<head>
    <title>The title of your page</title>
</head>
<body>
<iframe src="http://wibx950.com/"></iframe>
</body>

Upvotes: -1

Brock Adams
Brock Adams

Reputation: 93533

For the kind of popup given in your question, changing the title is simplicity itself. Merely set the script to run on the URL of the popup and then use document.title

Here is a complete working script that operates on the "Listen Now" popup of that page:

// ==UserScript==
// @name     _Change popup title
// @match    *://wibx950.com/listen-live/popup/
// @grant    none
// ==/UserScript==

document.title = "WKRP";

If you have a more intractable example, post a link/recipe to/for it.

Upvotes: 2

Related Questions