Ad

Userscript To Strip A Portion Of A Pages Title

IMDb's reference view was recently changed to include "- Reference View - IMDb" after the page title that only used to have Movie (year)

New...

<title>Movie Title (2018) - Reference View - IMDb</title>

Old...

<title>Movie Title (2018)</title>

How do i strip the stuff they added to the reference pages so I just have Title (year)?

// ==UserScript==
// @name        IMDb - strip garbage from reference view page titles
// @match       *://www.imdb.com/title/tt*/reference

Code makes my head spin and the above is all I can manage.

Ad

Answer

It's a matter of asking Google the right question. In your case, I searched for "how to change html title with javascript", the first result was javascript - How to dynamically change a web page's title? - Stack Overflow.

It's as simple as:

// ==UserScript==
// @name        IMDb - strip garbage from reference view page titles
// @match       *://www.imdb.com/title/tt*/reference
// ==/UserScript==

var newtitle = document.title;
newtitle = newtitle.replace(' - Reference View - IMDb','');
document.title = newtitle;
Ad
source: stackoverflow.com
Ad