Need help with a Stylish/Greasemonkey script

Friday, March 23, 2012 by Bebi Bulma | Discussion: Personal Computing

Hey guys, I was wondering if someone could help me with creating a Stylish script. Nothing extravagant, I just want a script to replace font A with font B universally on all websites. Does anyone know how to code that? Thanks.

frankell
Reply #1 Saturday, March 24, 2012 5:13 AM

try this forTahoma or change the font name and size as you like

 

body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}

hope this helps !

body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
frankell
Reply #2 Saturday, March 24, 2012 3:10 PM

well the first Stylish style is a "Global" style and will replace all the A, C, D, E ... fonts  to B on all websites

but if you want to replace only that specific font A to B go on with the following "Site" style just adding the sites that use the font A:

 

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document url-prefix('https://www.wincustomize.com')
{
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
}

@-moz-document url-prefix('https://forums.wincustomize.com')
{
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
}

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document url-prefix('https://www.wincustomize.com')


{
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
}

@-moz-document url-prefix('https://forums.wincustomize.com')

{
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
}
@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document url-prefix('https://www.wincustomize.com')


{
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
}

@-moz-document url-prefix('https://forums.wincustomize.com')

{
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
}
@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document url-prefix('https://www.wincustomize.com')


{
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
}

@-moz-document url-prefix('https://forums.wincustomize.com')

{
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
}
@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document url-prefix('https://www.wincustomize.com')


{
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
}

@-moz-document url-prefix('https://forums.wincustomize.com')

{
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
}
@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document url-prefix('https://www.wincustomize.com')


{
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
}

@-moz-document url-prefix('https://forums.wincustomize.com')

{
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
}
@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document url-prefix('https://www.wincustomize.com')


{
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
}

@-moz-document url-prefix('https://forums.wincustomize.com')

{
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
}


@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document url-prefix('https://www.wincustomize.com')


{
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
}

@-moz-document url-prefix('https://forums.wincustomize.com')

{
body, td, input, textarea, select, a, h, span, div {
font-size: 8pt !important;
font-family: Tahoma !important;
}
}
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document url-prefix('https://www.wincustomize.com')

{
body, td, input, textarea, select, a, h, span, div {
font-size: 10pt !important;
font-family: Tahoma !important;
}
}
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document url-prefix('https://www.wincustomize.com')

{
body, td, input, textarea, select, a, h, span, div {
font-size: 10pt !important;
font-family: Tahoma !important;
}
}
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document url-prefix('https://www.wincustomize.com')

{
body, td, input, textarea, select, a, h, span, div {
font-size: 10pt !important;
font-family: Tahoma !important;
}
}
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document url-prefix('https://www.wincustomize.com')

{
body, td, input, textarea, select, a, h, span, div {
font-size: 10pt !important;
font-family: Tahoma !important;
}
}
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document url-prefix('https://www.wincustomize.com')

{
body, td, input, textarea, select, a, h, span, div {
font-size: 10pt !important;
font-family: Tahoma !important;
}
}
Bebi Bulma
Reply #3 Tuesday, March 27, 2012 12:54 AM

Hmm, it looks like that will just replace ALL fonts. I'm specifically looking to replace only one font with another one.

 

Example: internet is using Comic Sans and Verdana. I want to replace Comic Sans with Segoe and leave Verdana as it is.

 

Maybe Stylish isn't capable of this, perhaps Greasemonkey? I don't care which, whatever works.

seanw3
Reply #4 Tuesday, March 27, 2012 4:04 AM

The best fit solution would be a product that replaces all other people's fonts with the ones you desire. Stardock, get on this and make millions.

frankell
Reply #5 Tuesday, March 27, 2012 7:51 AM

I don't use greasemonkey  but as

The HTML Body ( <body> ) element represents the main content of an HTML document. There is only one <body> element in a document.

The input ( <input> ) element is used to create interactive controls ... and so on

try to identify the element or elements that use Comic Sans and keep only them on the script so the other elements will not be replaced, for example

 

body, td, input, textarea, select, a, h, span, div {

{
font-family: Segoe !important;
}

and I use  Stylish (mainly the "App" styles)  to customize the Firefox appearence for example

 

frankell
Reply #6 Tuesday, March 27, 2012 5:12 PM

ok I started to use greasemonkey as I was curious to find a solution and here I am

first I found this script " http://userscripts.org/scripts/review/29876

then I modded the script for your needs 

 

// ==UserScript==
// @name          Comic Sans to Segoe font
// @namespace     for bb
// @include     *
// ==/UserScript==

var elementList = document.getElementsByTagName('*');
    for (var i = elementList.length - 1; i >= 0; i--) {
        var elementItem = elementList[i];
        var style = getComputedStyle(elementItem, '');
                elementItem.style.fontFamily = style.fontFamily.replace(/Comic Sans MS/i, 'segoe');

}

 

Bebi Bulma
Reply #7 Tuesday, March 27, 2012 9:04 PM

Ah now there we go.....if only I could get it to work, hmmm.

Nvm, got it! Didn't have the font name properly. I wonder if it changed the font here too, all of a sudden the text box font is tiny, even though I only have it set to replace awful comic sans, weird.

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01