Last active
May 31, 2023 06:41
-
-
Save megablue/3ffa1b36be6ad895695bd1bdd940164a to your computer and use it in GitHub Desktop.
Javascript to count total shares on Steam Hardware Survey by last month grouped by Nvidia, AMD, Intel and Others. intended to run on browser's javascript console.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
let nvidia = amd = intel = others = 0.0; | |
let gpGF10 = gpGF16 = gpGF20 = gpGF30 = gpGF40 = gpGFETC = gpRX400 = gpRX500 = gpRX5000 = gpRX6000 = gpRX7000 = gpAMDETC = gpIntelETC = 0.0; | |
let substats = document.getElementById("sub_stats"); | |
let divs = substats.getElementsByTagName("div"); | |
let rows = []; | |
for (let x = 0, headcounter = 0; x < divs.length; x++) { | |
if(divs[x].className.includes("substats_col_left col_header")) ++headcounter; | |
if(headcounter < 2) continue; | |
if(headcounter > 2) break; | |
if(divs[x].className.includes("substats_row")) rows.push(divs[x]); | |
} | |
for (let i = 0; i < rows.length; i++) { | |
let hwsFlexElements = rows[i].getElementsByClassName("hws_flex"); | |
let pctFlexElements = rows[i].getElementsByClassName("substats_col_month_last_pct"); | |
let brand = ''; | |
let pct = 0.0; | |
for (let j = 0; j < hwsFlexElements.length; j++) { | |
let spanElement = hwsFlexElements[j].getElementsByTagName("span")[0]; | |
brand = spanElement.textContent.toLowerCase(); | |
} | |
for (let k = 0; k < pctFlexElements.length; k++) { | |
let spanElement = pctFlexElements[k].getElementsByTagName("strong")[0]; | |
pct = parseFloat(spanElement.textContent); | |
} | |
if(brand.includes('nvidia')){ | |
nvidia += pct; | |
console | |
if(brand.includes('gtx 10')){ | |
gpGF10 += pct; | |
}else if(brand.includes('gtx 16')){ | |
gpGF16 += pct; | |
}else if(brand.includes('rtx 20')){ | |
gpGF20 += pct; | |
}else if(brand.includes('rtx 30')){ | |
gpGF30 += pct; | |
}else if(brand.includes('rtx 40')){ | |
gpGF40 += pct; | |
}else { | |
gpGFETC += pct; | |
} | |
}else if(brand.includes('amd')){ | |
amd += pct; | |
if(brand.match(/rx 4\d{2}$/)){ | |
gpRX400 += pct; | |
} else if(brand.match(/rx 5\d{2}$/)){ | |
gpRX500 += pct; | |
} else if(brand.match(/rx 5\d{3}/)){ | |
gpRX5000 += pct; | |
} else if(brand.match(/rx 6\d{3}/)){ | |
gpRX6000 += pct; | |
} else if(brand.match(/rx 7\d{3}/)){ | |
gpRX7000 += pct; | |
} else { | |
gpAMDETC += pct; | |
} | |
}else if(brand.includes('intel')) { | |
intel += pct; | |
}else{ | |
others += pct; | |
} | |
} | |
console.log("Total GPUs: " + rows.length); | |
console.log("Group by Brands"); | |
console.log("Nvidia total market share: " + nvidia.toFixed(2)); | |
console.log("AMD total market share: " + amd.toFixed(2)); | |
console.log("Intel total market share: " + intel.toFixed(2)); | |
console.log("Others total market share: " + others.toFixed(2)); | |
console.log("\nGroup by Series"); | |
console.log("Nvidia GTX 10xx: " + gpGF10.toFixed(2)); | |
console.log("Nvidia GTX 16xx: " + gpGF16.toFixed(2)); | |
console.log("Nvidia RTX 20xx: " + gpGF20.toFixed(2)); | |
console.log("Nvidia RTX 30xx: " + gpGF30.toFixed(2)); | |
console.log("Nvidia RTX 40xx: " + gpGF40.toFixed(2)); | |
console.log("Nvidia others: " + gpGFETC.toFixed(2)); | |
console.log("AMD Radeon RX4xx: " + gpRX400.toFixed(2)); | |
console.log("AMD Radeon RX5xx: " + gpRX500.toFixed(2)); | |
console.log("AMD Radeon RX5xxx: " + gpRX5000.toFixed(2)); | |
console.log("AMD Radeon RX6xxx: " + gpRX6000.toFixed(2)); | |
console.log("AMD Radeon RX7xxx: " + gpRX7000.toFixed(2)); | |
console.log("AMD Others: " + gpAMDETC.toFixed(2)); | |
console.log("Intel Others: " + intel.toFixed(2)); | |
console.log("Others: " + others.toFixed(2)); | |
console.log("\nCSV\n"); | |
//CSVs | |
let output = ''; | |
output += "Brands,Percentage" + '\r\n'; | |
output += "Nvidia," + nvidia.toFixed(2) + '\r\n'; | |
output += "AMD," + amd.toFixed(2) + '\r\n'; | |
output += "Intel," + intel.toFixed(2) + '\r\n'; | |
output += "Others," + others.toFixed(2) + '\r\n'; | |
output += "Series,Percentage" + '\r\n'; | |
output += "Nvidia GTX 10xx," + gpGF10.toFixed(2) + '\r\n'; | |
output += "Nvidia GTX 16xx," + gpGF16.toFixed(2) + '\r\n'; | |
output += "Nvidia RTX 20xx," + gpGF20.toFixed(2) + '\r\n'; | |
output += "Nvidia RTX 30xx," + gpGF30.toFixed(2) + '\r\n'; | |
output += "Nvidia RTX 40xx," + gpGF40.toFixed(2) + '\r\n'; | |
output += "Nvidia others," + gpGFETC.toFixed(2) + '\r\n'; | |
output += "AMD Radeon RX4xx," + gpRX400.toFixed(2) + '\r\n'; | |
output += "AMD Radeon RX5xx," + gpRX500.toFixed(2) + '\r\n'; | |
output += "AMD Radeon RX5xxx," + gpRX5000.toFixed(2) + '\r\n'; | |
output += "AMD Radeon RX6xxx," + gpRX6000.toFixed(2) + '\r\n'; | |
output += "AMD Radeon RX7xxx," + gpRX7000.toFixed(2) + '\r\n'; | |
output += "AMD Others," + gpAMDETC.toFixed(2) + '\r\n'; | |
output += "Intel Others," + intel.toFixed(2) + '\r\n'; | |
output += "Others," + others.toFixed(2) + '\r\n'; | |
console.log(output); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment