简体   繁体   中英

How to remove unwanted clutter from all of the individual page titles on a website?

A forum I am using has the long name of the site first, then the page-name of the thread in the title. So, I only can see the first 2 characters of the thread name in browser tabs.

I used this "Change Page Title" script but it only changes one page's title at a time. How can I delete the superlongwebsitename on the title bar for all pages?

I want to change it so when I enter to any page on the site it shows only the thread name (the aforementioned script requires an entry for each individual page).

For HTML like this:

<meta name="description" content="superlongsitename / threadname" />
<title>superlongsitename / threadname</title>

I want the script to seek and delete the "superlongsitename" in all pages for a given site.

I tried this:

newString = str.replace("Tarantula&nbsp;- Sekiz Bacakli Güzeller /", )

but it didn't work.

That site uses unicode characters which sometimes require special handling in regular expressions . But, fortunately, the site conveniently puts all of the cruft before a slash character ( / ).

So, you can use a regex like /^[^\\/]+\\/\\s*/ to catch it.

Here's a complete script that fixes the title:

// ==UserScript==
// @name        _Tarantula, smarter, less cluttered title.
// @namespace   tarantula.gen
// @include     http://www.tarantula.gen.tr/forum/*
// @include     https://www.tarantula.gen.tr/forum/*
// ==/UserScript==

//--- Delete everything before the first slash (/).
var newTitle    = document.title.replace (/^[^\/]+\/\s*/, "");
document.title  = newTitle;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM