Go Back   Flash Flash Revolution > General Discussion > Technology
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
Old 05-20-2013, 07:51 PM   #21
dAnceguy117
new hand moves = dab
FFR Simfile AuthorFFR Veteran
 
dAnceguy117's Avatar
 
Join Date: Dec 2002
Location: he/they
Age: 33
Posts: 10,094
Default Re: Java/Greasemonkey problem

Quote:
Originally Posted by noname219 View Post
The script acts everytime you load an artist page. (supposing you already have downloaded the Greasemonkey extension for Firefox/Chrome)
I haven't, haha. will grab it soon!
dAnceguy117 is offline   Reply With Quote
Old 06-1-2013, 05:51 PM   #22
dAnceguy117
new hand moves = dab
FFR Simfile AuthorFFR Veteran
 
dAnceguy117's Avatar
 
Join Date: Dec 2002
Location: he/they
Age: 33
Posts: 10,094
Default Re: Java/Greasemonkey problem

working on this

right now

so sorry for the holdup




edit:

GOT IT! I hope.


Code:
// ==UserScript== 
// @name       RYM Artist Rating 
// @version    0.2 
// @description  Compiles all RYM Artist Page data and displays the Artist rating beside the artist name 
// @match      http://rateyourmusic.com/artist/* 
// @copyright  2012+, quiapz, AnniesBoobs 

// also danceguy made some modifications. wow he's so cool

// ==/UserScript== 
function parseAlbum(albumType) {
    var albums = (document.getElementById(albumType));
    if (albums != null) {
        albums = albums.getElementsByTagName('tr');

        // get number of albums for this section, including appearances.
        numAlbums += (albums.length - 2);
		
	// EXCLUDE those appearances.
	for (var j = 2; j < albums.length; j++)
	{
		albumRow = albums[j];
			
		// IF the "title" element contains "Appears" THEN exclude the album from the running total.
		if (albumRow.cells[1].textContent.indexOf("Appears") !== -1)
			numAlbums--;
	}

        var artistRating = albums.length;
        for (var j = 2; j < artistRating; j++) {
            albumRow = albums[j];
            if ((!albumRow.hasAttribute("class")) && (albumRow.cells[4].textContent != '') && (albumRow.cells[6].textContent != '')) {
                ratings = parseInt((albumRow.cells[4].textContent).replace(/\,/g, ''));
                score = parseFloat(albumRow.cells[6].textContent);
                ratingCtr = ratingCtr + ratings;
                scoreCtr = scoreCtr + score;
                totCtr = totCtr + (ratings * score);
                if (albumType != 'album_disc_c') {
                    if (1919 < albumRow.cells[0].textContent && albumRow.cells[0].textContent < 1930) {
                        decadeStats[0][1] = decadeStats[0][1] + (ratings * score);
                        decadeStats[0][2] = decadeStats[0][2] + ratings;
                    } else if (1929 < albumRow.cells[0].textContent && albumRow.cells[0].textContent < 1940) {
                        decadeStats[1][1] = decadeStats[1][1] + (ratings * score);
                        decadeStats[1][2] = decadeStats[1][2] + ratings;
                    } else if (1939 < albumRow.cells[0].textContent && albumRow.cells[0].textContent < 1950) {
                        decadeStats[2][1] = decadeStats[2][1] + (ratings * score);
                        decadeStats[2][2] = decadeStats[2][2] + ratings;
                    } else if (1949 < albumRow.cells[0].textContent && albumRow.cells[0].textContent < 1960) {
                        decadeStats[3][1] = decadeStats[3][1] + (ratings * score);
                        decadeStats[3][2] = decadeStats[3][2] + ratings;
                    } else if (1959 < albumRow.cells[0].textContent && albumRow.cells[0].textContent < 1970) {
                        decadeStats[4][1] = decadeStats[4][1] + (ratings * score);
                        decadeStats[4][2] = decadeStats[4][2] + ratings;
                    } else if (1969 < albumRow.cells[0].textContent && albumRow.cells[0].textContent < 1980) {
                        decadeStats[5][1] = decadeStats[5][1] + (ratings * score);
                        decadeStats[5][2] = decadeStats[5][2] + ratings;
                    } else if (1979 < albumRow.cells[0].textContent && albumRow.cells[0].textContent < 1990) {
                        decadeStats[6][1] = decadeStats[6][1] + (ratings * score);
                        decadeStats[6][2] = decadeStats[6][2] + ratings;
                    } else if (1989 < albumRow.cells[0].textContent && albumRow.cells[0].textContent < 2000) {
                        decadeStats[7][1] = decadeStats[7][1] + (ratings * score);
                        decadeStats[7][2] = decadeStats[7][2] + ratings;
                    } else if (1999 < albumRow.cells[0].textContent && albumRow.cells[0].textContent < 2010) {
                        decadeStats[8][1] = decadeStats[8][1] + (ratings * score);
                        decadeStats[8][2] = decadeStats[8][2] + ratings;
                    } else if (2009 < albumRow.cells[0].textContent && albumRow.cells[0].textContent < 2020) {
                        decadeStats[9][1] = decadeStats[9][1] + (ratings * score);
                        decadeStats[9][2] = decadeStats[9][2] + ratings;
                    }
                }
                if (!isNaN(parseInt(albumRow.cells[7].textContent))) {
                    youRating = youRating + parseFloat(albumRow.cells[7].textContent.substring(0, 4));
                    youRated++;
                }
            }
        }
    }
}

function addCommas(nStr) {
    nStr += '';
    y = nStr.split('.');
    y1 = y[0];
    y2 = y.length > 1 ? '.' + y[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(y1)) {
        y1 = y1.replace(rgx, '$1' + ',' + '$2');
    }
    return y1 + y2;
}
// Go through the Album discography and compute Artist Rating using Ratings and Overall Score of each album 
var ratingCell, scoreCell, albumRow;
var numUnfilteredAlbums = 0;
var numAlbums = 0;
var scoreCtr = 0;
var ratingCtr = 0;
var totCtr = 0;
var youRating = 0;
var youRated = 0;
var decadeStats = [
    ['1920s: ', 0, 0],
    ['1930s: ', 0, 0],
    ['1940s: ', 0, 0],
    ['1950s: ', 0, 0],
    ['1960s: ', 0, 0],
    ['1970s: ', 0, 0],
    ['1980s: ', 0, 0],
    ['1990s: ', 0, 0],
    ['2000s: ', 0, 0],
    ['2010s: ', 0, 0]
];
parseAlbum('album_disc_s');
parseAlbum('album_disc_i');
parseAlbum('album_disc_e');
parseAlbum('album_disc_b');
parseAlbum('album_disc_d');
parseAlbum('album_disc_t');
parseAlbum('album_disc_c');
// Display the data under the artist name as the first row of the profile table 
if (ratingCtr > 0) {
    var mbgens = document.getElementsByClassName('mbgen');
    var bio = mbgens[0];
    var row = bio.insertRow(0);
    var newCell;

    if (youRated > 0) {
        x = (-((totCtr / ratingCtr).toFixed(9) - (youRating / youRated).toFixed(9)).toFixed(9));
        if (x >= 0) {
            x = '+' + x.toFixed(9);
        }
        // include the number of albums in the second element of the row.
        var rowValues = ['Artist Rating', (totCtr / ratingCtr).toFixed(9) + ' from ' + addCommas(ratingCtr) + ' ratings and ' + numAlbums + ' releases, Your rating: ' + (youRating / youRated).toFixed(9) + ' from ' + addCommas(youRated) + ' ratings (RYM ' + x + ')'];
    } else {
        // include the number of albums in the second element of the row.
        var rowValues = ['Artist Rating', (totCtr / ratingCtr).toFixed(9) + ' from ' + addCommas(ratingCtr) + ' ratings and ' + numAlbums + ' releases'];
    }
    for (var i = 0, ii = rowValues.length; i < ii; i++) {
        newCell = row.insertCell(i);
        newCell.appendChild(document.createTextNode(rowValues[i]));
    }

    var row = bio.insertRow(bio.getElementsByTagName("TR").length);
    var newCell;
    newCell1 = row.insertCell(0);
    newCell1.appendChild(document.createTextNode('Music stats'));
    newCell = row.insertCell(1);
    x = document.createElement('b');
    newCell.appendChild(x);
    x.appendChild(document.createTextNode('Average by Decade:'));
    for (d = 0; d < decadeStats.length; d++) {
        if (decadeStats[d][2] > 0) {
            newCell.appendChild(document.createElement('br'));
            newCell.appendChild(document.createTextNode(decadeStats[d][0] + (decadeStats[d][1] / decadeStats[d][2]).toFixed(2) + ', from ' + addCommas(decadeStats[d][2]) + ' ratings'));
        }
    }
}


Let me know what you think!

Possible issue: an album would be excluded from the total if its title contains the word "Appears" lol. Holla back if that will be a problem.

Last edited by dAnceguy117; 06-1-2013 at 07:44 PM..
dAnceguy117 is offline   Reply With Quote
Old 06-1-2013, 07:58 PM   #23
noname219
FFR Wiki Admin
Wiki Administrator
Retired StaffFFR Veteran
 
noname219's Avatar
 
Join Date: May 2007
Location: Quebec, Canada
Age: 33
Posts: 1,694
Send a message via Skype™ to noname219
Default Re: Java/Greasemonkey problem

This is exactly what I wanted. Huge thanks! ;)

If you're curious why I needed this : http://rateyourmusic.com/list/noname219/top_artists
Basically, the script will automatically calculate the avg. rating, number of ratings and number of albums for every artist page I'm gonna load from now on. (I was doing this by copy/pasting the data in a Excel file and that was time consumming...)

Sent you as well some caps.
noname219 is offline   Reply With Quote
Old 06-1-2013, 08:01 PM   #24
dAnceguy117
new hand moves = dab
FFR Simfile AuthorFFR Veteran
 
dAnceguy117's Avatar
 
Join Date: Dec 2002
Location: he/they
Age: 33
Posts: 10,094
Default Re: Java/Greasemonkey problem

:D

we have a good number of those top artists in common, by the way!
dAnceguy117 is offline   Reply With Quote
Old 06-1-2013, 08:15 PM   #25
noname219
FFR Wiki Admin
Wiki Administrator
Retired StaffFFR Veteran
 
noname219's Avatar
 
Join Date: May 2007
Location: Quebec, Canada
Age: 33
Posts: 1,694
Send a message via Skype™ to noname219
Default Re: Java/Greasemonkey problem

It's the average rating of all registered members from the website, not from my personnal subjective pov. But if you're curious, you can check (http://rateyourmusic.com/collection/noname219/r4.5-5.0) or (http://rateyourmusic.com/list/noname...onus___cookie_) for stuff that I like the most.

If you're interested, I can create lists like this from every possible existing music genre (it just have to be listed on the website).
noname219 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 11:27 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright FlashFlashRevolution