Greasemonkeys » Discussions

Last.fm Compatibility Percentage

 
    • iriebob a dit :...
    • Abonné
    • 27 jui. 2008, 12h26m

    Last.fm Compatibility Percentage

    A tiny script with a complicated name. It's purpose is to display the percentage value in the compatibility bar on user pages. Hope you'll enjoy!

    download link

    • jarikata a dit :...
    • Utilisateur
    • 27 jui. 2008, 15h35m
    Nice!

  • Cool. Yet another thing I was missing in the new Last.fm. Thanks!

    • cabinet a dit :...
    • Utilisateur
    • 29 jui. 2008, 8h11m
    very nice. thanks!

    • spacefish a dit :...
    • Utilisateur
    • 30 jui. 2008, 5h42m
    Sweet, thanks! Added.

    • _Tarkus_ a dit :...
    • Utilisateur
    • 30 jui. 2008, 8h09m
    Very useful addition indeed! Thanks!

    • spacefish a dit :...
    • Utilisateur
    • 17 sept. 2008, 14h33m
    Looks like this one broke in a recent update. (Today?)

    • _Tarkus_ a dit :...
    • Utilisateur
    • 17 sept. 2008, 15h46m
    Yeah, I see they changed the design. I like the new look better, even though it broke this script.

  • spacefish said:
    Looks like this one broke in a recent update. (Today?)


    Yeah :(

    • iriebob a dit :...
    • Abonné
    • 20 sept. 2008, 7h39m
    I've updated the script to work with the recent layout changes.

    At my testings I've noticed that the layout changes are only introduced on the english version of lastfm so far. I've no clue if the old script was working with the other language sites, but this new one is only for the english site with the changed layout.

    Get the update here.

    • _Tarkus_ a dit :...
    • Utilisateur
    • 20 sept. 2008, 9h15m
    Thanks for the update! Nice to have the percentages back...

    • ViggenZ a dit :...
    • Utilisateur
    • 21 sept. 2008, 20h16m
    cool, thx

    boo!
    • pimmka a dit :...
    • Abonné
    • 30 sept. 2008, 18h25m
    Thanks for the update! :)


    last impression
  • It's not showing percentages for me..
    Anyone else have this problem?

    • klatch a dit :...
    • Utilisateur
    • 8 jan. 2009, 17h17m
    Yes. With the recent changes in Last.fm's taste-o-meter, I think it will only show itself with rounded percentages. (e.g. 0% or 100%)

  • Well that sucks. :( I really liked this script.

    • klatch a dit :...
    • Utilisateur
    • 9 jan. 2009, 16h23m
    Well, I recommend you redownload the script when it's been updated, but until then, you could change it yourself so it works again by editing the script and:

    Replacing:
    - var r = /^(\d+)(%)$/;
    With:
    - var r = /^(\d+)(.)(\d+)(%)$/;

    Replacing:
    - if (RegExp.$2 == "%") {
    With:
    - if (RegExp.$4 == "%") {

    (leave the next one out if you don't want rounded numbers)
    Adding:
    - s = Math.round(RegExp.$1 + RegExp.$2 + RegExp.$3) + '%';
    Under the previous one.


    However, this won't show you a percentage when it really is 0%. (pre-rounded)

  • Aw thanks! That worked. :D Awesome.

    • Alan71 a dit :...
    • Utilisateur
    • 12 jan. 2009, 1h20m
    I haven't tried it, but:

    var r = /^(\d+.?\d*)(%)$/;

    while keeping:

    if (RegExp.$2 == "%") {

    and for rounded percentages:

    s = Math.round(RegExp.$1) + '%';

    should do the trick.

    • Alan71 a dit :...
    • Utilisateur
    • 12 jan. 2009, 1h39m
    OK, I got bored and I fixed it.

    I added support for i18n'd versions.

    update here

    • klatch a dit :...
    • Utilisateur
    • 13 jan. 2009, 11h28m
    Thanks Alan71, for providing a better solution. :)

    (JavaScript RegEx freaks me out)

    • Alan71 a dit :...
    • Utilisateur
    • 13 jan. 2009, 15h10m
    it's probably not the best solution, which should be something like:
    /(\d+[.]?\d*)%/
    while testing if exec matches something in the string, but that works and I didn't want to alter his code that much.

    quick recap on regexp repetition operators (quantifiers):
    {x} --> x times
    {x,} --> x or more times
    {x,y} --> between x and y times
    * --> {0,}
    ? --> {0,1}
    + --> {1,}

    switching between greedy and lazy repetition operators (quantifiers) by using "?" (which has many different meanings):
    />(.*)</.exec("<div><p>...</p></div>") --> {"<p>...</p>"}
    />(.*?)</.exec("<div><p>...</p></div>") --> {"<p>..."}

    • snyde1 a dit :...
    • Abonné
    • 13 jan. 2009, 20h02m
    FWIW, I use:
    /([0-9\.]*)%/
    I guess it also matches leading and trailing decimal points, but I don't see those being added.

    Did I hear that right? Mondegreens - for the misheard word.
    Like Odds? Can't get better than Even Odds!

    Speak your truth quietly and clearly; and listen to others, even to the dull and the ignorant; they too have their story.
    • Alan71 a dit :...
    • Utilisateur
    • 14 jan. 2009, 16h43m
    This would work, but would also match "00.000.000" and even an empty string "".

    • snyde1 a dit :...
    • Abonné
    • 14 jan. 2009, 23h33m
    Alan71 said:
    This would work, but would also match "00.000.000" and even an empty string "".
    Yes, but it is supposed to be a percentage and those would both go to NaN, which in this case I'd set to zero.

    Did I hear that right? Mondegreens - for the misheard word.
    Like Odds? Can't get better than Even Odds!

    Speak your truth quietly and clearly; and listen to others, even to the dull and the ignorant; they too have their story.
Les utilisateurs anonymes ne peuvent pas poster de messages. Merci de vous connecter ou de créer un compte pour pouvoir intervenir dans les forums.