Last.fm Compatibility Percentage

 
    • iriebob said...
    • Subscriber
    • 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

  • Nice!

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

    • cabinet said...
    • User
    • 29 Jul 2008, 08:11
    very nice. thanks!

  • Sweet, thanks! Added.

  • Very useful addition indeed! Thanks!

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

  • 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 said...
    • Subscriber
    • 20 Sep 2008, 07: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.

  • Thanks for the update! Nice to have the percentages back...

    • ViggenZ said...
    • User
    • 21 Sep 2008, 20:16
    cool, thx

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


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

    • klatch said...
    • User
    • 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 said...
    • User
    • 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 said...
    • User
    • 12 Jan 2009, 01: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 said...
    • User
    • 12 Jan 2009, 01:39
    OK, I got bored and I fixed it.

    I added support for i18n'd versions.

    update here

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

    (JavaScript RegEx freaks me out)

    • Alan71 said...
    • User
    • 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 said...
    • Subscriber
    • 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.

    Improve your view of Last.fm - add some User Scripts.
    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 said...
    • User
    • 14 Jan 2009, 16:43
    This would work, but would also match "00.000.000" and even an empty string "".

    • snyde1 said...
    • Subscriber
    • 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.

    Improve your view of Last.fm - add some User Scripts.
    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.
Anonymous users may not post messages. Please log in or create an account to post in the forums.