yahoo mail logo

95 views
Skip to first unread message

ddjen11

unread,
Aug 20, 2011, 2:28:47 PM8/20/11
to greasemon...@googlegroups.com
hi,

i just started using the new yahoo email, am trying to replace or hide the logo which is a background image. i;ve done this in prior version of yahoo mail. my problem is this genecic code does not seem to work under new mail:

for (i=0;.....) {

if (document.styleSheets[i].cssRules) 
      thecss = document.styleSheets[i].cssRules;
else
 { 
     if (document.styleSheets[x].rules)      
            thecss = document.styleSheets[i].rules;  
     else
          return;
 }}

it does work for another web site.  any help is appreciated.
tia
David

ddjen11

unread,
Aug 20, 2011, 7:38:51 PM8/20/11
to greasemon...@googlegroups.com
stripped down to just this code-

if (document.styleSheets){
   
    var thecss = new Array();

  var len=document.styleSheets.length;
 
  for (x=0;x<len;x++)
  {
     alert('sheet '+x+' of '+len);
        if (document.styleSheets[0].rules) 
              alert('IE');
     else
           if (document.styleSheets[0].cssRules) 
                alert('FF');
            else
                   alert('unknown');
 
  }
}

i think there's an error & stopped running when it encountered the expression:

 "document.styleSheets[0].cssRules"

i cannot tell why - it worked for other sites. anybody has any insight?
thanks

LWChris@LyricWiki

unread,
Aug 21, 2011, 9:12:05 AM8/21/11
to greasemon...@googlegroups.com
Am 21.08.2011 01:38, schrieb ddjen11:
> stripped down to just this code-
>
> if (document.styleSheets){
>
> var thecss = new Array();
>
> var len=document.styleSheets.length;
>
> for (x=0;x<len;x++)
> {
> alert('sheet '+x+' of '+len);
> if (document.styleSheets[0].rules)
> alert('IE');
> else
> if (document.styleSheets[0].cssRules)
> alert('FF');
> else
> alert('unknown');
>
> }
> }
>

Maybe add curled braces to exclude the error there. Is it allowed to
have the semicolon in front of the "else"? (I always added braces so
I've never cared about that problem...)
Can you access the document.styleSheets[0].disabled property? What value
does "len" have? Try also if (document.styleSheets[0]){alert("Exists");}

Michal Wojciechowski

unread,
Aug 21, 2011, 7:42:53 PM8/21/11
to greasemon...@googlegroups.com
On 08/21/2011 01:38 AM, ddjen11 wrote:

> i think there's an error & stopped running when it encountered the
> expression:
>
> "document.styleSheets[0].cssRules"
>
> i cannot tell why - it worked for other sites. anybody has any insight?

If you just need to modify the CSS rules on the page, you can use
GM_addStyle (http://wiki.greasespot.net/GM_addStyle).

--
Michal Wojciechowski
http://odyniec.net/ | http://userscripts.org/users/49673

Michal Wojciechowski

unread,
Aug 21, 2011, 7:49:19 PM8/21/11
to greasemon...@googlegroups.com
On 08/21/2011 03:12 PM, LWChris@LyricWiki wrote:

> Is it allowed to have the semicolon in front of the "else"?

Yes, it is. This is JavaScript, not Pascal :)

ddjen11

unread,
Aug 21, 2011, 11:14:32 PM8/21/11
to greasemon...@googlegroups.com
thx for the response.

- document.styleSheets[0].disabled = false;
- len = 4 (style sheets)
-  if (document.styleSheets[0]){alert("Exists");} = Exists

ddjen11

unread,
Aug 21, 2011, 11:19:36 PM8/21/11
to greasemon...@googlegroups.com
yes i was able to move up the logo using GM_addStyle by doing "div.nav-bar { top:144px }", this gets rid of a big spaces between tabs and the logo. what i was able to do before was replacing the logo. the code does not work now, appears to trip on the expression: "document.styleSheets[x].cssRules", but no errors on Error Console.

ddjen11

unread,
Aug 21, 2011, 11:52:55 PM8/21/11
to greasemon...@googlegroups.com
the reason i think the expression is the issue is if I changed the literal text "cssRules" to anything else it would not error & stop execution, it will not do what I wanted but does not stop the rest of GM script.

in short, this wont work & stops GM execution:

document.styleSheets[x].cssRules

but all these undefined elms will continue the rest of code:

document.styleSheets[x].cssRules1
document.styleSheets[x].cssRulesx
document.styleSheets[x].cssRules123
document.styleSheets[x].cssRulesxyz

any clues?

Michal Wojciechowski

unread,
Aug 22, 2011, 2:34:41 AM8/22/11
to greasemon...@googlegroups.com
On 08/22/2011 05:19 AM, ddjen11 wrote:

> yes i was able to move up the logo 
> using GM_addStyle by doing "div.nav-bar { top:144px
> }", this gets rid of a big spaces 
> between tabs and the logo. what i 
> was able to do before was replacing 
> the logo.

Is anything stopping you from using GM_addStyle to also replace the logo?

ddjen11

unread,
Aug 22, 2011, 10:25:23 AM8/22/11
to greasemonkey-users
here's the original code -

<div class="yuhead-logo">
<style>
.yuhead-logo
h2{
width:200px;
height:30px;
background-image:url(http://l.yimg.com/a/i/brand/
purplelogo/uh/20/minty/logo-ymail-wh.png);
_background-image:url(http://l.yimg.com/a/i/brand/
purplelogo/uh/20/minty/logo-ymail-wh.ie6.png);}
.yuhead-logo
a{
width:200px;
height:30px; }
.yuhead-logo
div.yuhead-comarketing {
width:200px; }
</style>

<h2>
<a href="http://us.lrd.yahoo.com/
_ylt=AhZnv59vdspPCOmL2qcrfr2huVI6/SIG=11ap1seuq/EXP=1314977732/**http
%3A//mail.yahoo.com/" target="_top">
Yahoo! Mail
</a>
</h2> <!-- comarketing component -->
</div>


i dont quite understand the tag " _background-image:", its a
transparent logo image that overlays a white background
image(specified in "background-image" above it). my goal is to replace
the logo here. what will be the best way to do it? I tried adding a
"div.yuhead-logo.h2" style replacing bg image but that did not work...


On Aug 22, 1:34 am, Michal Wojciechowski <odyn...@odyniec.eu.org>
wrote:

Michal Wojciechowski

unread,
Aug 22, 2011, 10:43:06 AM8/22/11
to greasemon...@googlegroups.com
On 08/22/2011 04:25 PM, ddjen11 wrote:

> i dont quite understand the tag " _background-image:", its a
> transparent logo image that overlays a white background
> image(specified in "background-image" above it).

"_background-image" is an Internet Explorer 6 hack. The underscore at
the beginning makes it an incorrect CSS rule and browsers ignore it,
except for IE6, which accepts it. So it's basically a way to use a
different style for IE6 -- in this case, a different background image.

> my goal is to replace
> the logo here. what will be the best way to do it? I tried adding a
> "div.yuhead-logo.h2" style replacing bg image but that did not work...

"div.yuhead-logo.h2" means "a div having two classes, yuhead-logo and
h2", which is not what you want. This should work:

GM_addStyle(".yuhead-logo h2 { background-image: url(whatever); }");

ddjen11

unread,
Aug 22, 2011, 11:33:59 AM8/22/11
to greasemonkey-users
thanks for the explanation!

I tried this for a test -
GM_addStyle(".yuhead-logo h2 { background-image: url(http://l.yimg.com/
a/i/identity2/profile_16c.png); }");

still not workin:(

On Aug 22, 9:43 am, Michal Wojciechowski <odyn...@odyniec.eu.org>
wrote:

Michal Wojciechowski

unread,
Aug 22, 2011, 11:44:20 AM8/22/11
to greasemon...@googlegroups.com
On 08/22/2011 05:33 PM, ddjen11 wrote:

> I tried this for a test -
> GM_addStyle(".yuhead-logo h2 { background-image: url(http://l.yimg.com/
> a/i/identity2/profile_16c.png); }");
>
> still not workin:(

Try with !important, i.e.:

GM_addStyle(".yuhead-logo h2 { background-image:
url(http://l.yimg.com/a/i/identity2/profile_16c.png) !important; }");

ddjen11

unread,
Aug 22, 2011, 11:58:14 AM8/22/11
to greasemonkey-users
sorry forgot about that, now it is working, thanks a lot for your
help!!!

do you know why document.styleSheets[i].cssRules syntax would not
work, it simply stopped the rest of script on FF 3.6.20 ...would you
recommend GM_addStyle over that method?

On Aug 22, 10:44 am, Michal Wojciechowski <odyn...@odyniec.eu.org>
wrote:

Michal Wojciechowski

unread,
Aug 22, 2011, 1:22:00 PM8/22/11
to greasemon...@googlegroups.com
On 08/22/2011 05:58 PM, ddjen11 wrote:

> do you know why document.styleSheets[i].cssRules syntax would not
> work, it simply stopped the rest of script on FF 3.6.20 ...would you
> recommend GM_addStyle over that method?

Hard to say without actually debugging the script, but, yeah, I'd say
just go with GM_addStyle, as it is a much simpler method.

ddjen11

unread,
Aug 22, 2011, 4:12:03 PM8/22/11
to greasemonkey-users
great, thanks for all your help.

On Aug 22, 12:22 pm, Michal Wojciechowski <odyn...@odyniec.eu.org>
wrote:
Reply all
Reply to author
Forward
0 new messages