When you open a Wikipedia article such Apple, its title is:

Apple - Wikipedia, the free encyclopedia

Is there a Firefox extension to remove the useless - Wikipedia, the free encyclopedia part? I understand it is important for branding and SEO, but personally I know what Wikipedia is and I want to unclutter tab names, window titles, names of saved HTML files, headers or articles saved as PDF or printed, etc.

The Greasemonkey Firefox addon would enable you to do that. Greasemonkey lets you run "UserScripts" to be run on the page source, in order to modify it.1


1:Further details can be found at the Greasemonkey homepage, the corresponding Wikipedia page, and a collection of scripts at GreasyFork.

The userscript you'd need would be pretty simple, just running a regular expression replace on the page's <title> attribute. In pseudocode:

title = title.replace('^(.*)\s*- .+$','\1')

would cut off everything after a dash (including the dash and potential leading whitespaces). How to dynamically change a web page's title? could serve as a starting point here. Or, to make it easier for you, just use this:

// ==UserScript==
// @name        TitleStrip
// @namespace   IzzySoft
// @description Strips trailing site name from page title
// @include     *
// @version     1
// @grant       none
// ==/UserScript==
document.title = document.title.replace(/^(.*)\s*- .+$/,'$1')

Note that you might need to define some exceptions in case some sites uses titles that contain dashes. Picking up your example:

Apple - a fruit - Wikipedia, the free encyclopedia

I found no corresponding place to check it against; as my above script uses a "greedy wildcard", it should work as you want it, but I could not verify that.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.