Greasemonkeys » Diskussionen

Last.fm Compatibility Percentage

 
    • iriebob schrieb...
    • Abonnent
    • 27. Jul. 2008, 12:26

    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 schrieb...
    • Benutzer
    • 27. Jul. 2008, 15:35
    Nice!

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

    • cabinet schrieb...
    • Benutzer
    • 29. Jul. 2008, 8:11
    very nice. thanks!

    • spacefish schrieb...
    • Benutzer
    • 30. Jul. 2008, 5:42
    Sweet, thanks! Added.

    • _Tarkus_ schrieb...
    • Benutzer
    • 30. Jul. 2008, 8:09
    Very useful addition indeed! Thanks!

    • spacefish schrieb...
    • Benutzer
    • 17. Sep. 2008, 14:33
    Looks like this one broke in a recent update. (Today?)

    • _Tarkus_ schrieb...
    • Benutzer
    • 17. Sep. 2008, 15:46
    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 schrieb...
    • Abonnent
    • 20. Sep. 2008, 7:39
    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_ schrieb...
    • Benutzer
    • 20. Sep. 2008, 9:15
    Thanks for the update! Nice to have the percentages back...

    • ViggenZ schrieb...
    • Benutzer
    • 21. Sep. 2008, 20:16
    cool, thx

    boo!
    • pimmka schrieb...
    • Abonnent
    • 30. Sep. 2008, 18:25
    Thanks for the update! :)


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

    • klatch schrieb...
    • Benutzer
    • 8. Jan. 2009, 17:17
    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 schrieb...
    • Benutzer
    • 9. Jan. 2009, 16:23
    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 schrieb...
    • Benutzer
    • 12. Jan. 2009, 1:20
    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 schrieb...
    • Benutzer
    • 12. Jan. 2009, 1:39
    OK, I got bored and I fixed it.

    I added support for i18n'd versions.

    update here

    • klatch schrieb...
    • Benutzer
    • 13. Jan. 2009, 11:28
    Thanks Alan71, for providing a better solution. :)

    (JavaScript RegEx freaks me out)

    • Alan71 schrieb...
    • Benutzer
    • 13. Jan. 2009, 15:10
    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 schrieb...
    • Abonnent
    • 13. Jan. 2009, 20:02
    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 schrieb...
    • Benutzer
    • 14. Jan. 2009, 16:43
    This would work, but would also match "00.000.000" and even an empty string "".

    • snyde1 schrieb...
    • Abonnent
    • 14. Jan. 2009, 23:33
    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.
Anonyme Benutzer dürfen keine Beiträge schreiben. Bitte log dich ein oder registriere dich, um Beiträge in den Foren schreiben zu können.