Skip to content

Commit

Permalink
Extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Flakky committed Apr 15, 2024
1 parent a8e624a commit 674241b
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 0 deletions.
Empty file added background.js
Empty file.
83 changes: 83 additions & 0 deletions content_script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
var numberWithCommas = (x) => {
return x.toString().replace(/\B(?<!\.\d*)(?=(\d{3})+(?!\d))/g, ","); // https://stackoverflow.com/questions/2901102/how-to-format-a-number-with-commas-as-thousands-separators
}

var addSummaryNetRow = () => {
var table = document.querySelector('.lifetimeSummaryCtn table');
if (!table) return; // If no table is found, exit the function

console.log(table);

var rows = table.rows;
var netRevenueCell = rows[1].cells[1];
var netRevenue = netRevenueCell.textContent;
netRevenue = netRevenue.replace('$', '');
netRevenue = netRevenue.replace(',', '');
console.log(Number(netRevenue))
var devRevenue = Number(netRevenue * 0.7);
var devRevenueString = numberWithCommas(Math.floor(devRevenue));

var newRow = table.insertRow(2); // Insert after net

var nameElem = document.createElement('td');
var sumElem = document.createElement('td');
var descElem = document.createElement('td');
descElem.textContent = '(Net revenue for the developer. Net * 0.7)'
nameElem.textContent = 'Lifetime Steam revenue (developer net)';
sumElem.textContent = `$${devRevenueString}`
sumElem.setAttribute('align', 'right')
newRow.appendChild(nameElem);
newRow.appendChild(sumElem);
newRow.appendChild(descElem);

console.log("Steamworks Dev Net: Added summary net");
}

var addSalesNetRow = () => {
var parentElement = document.getElementById('gameDataLeft');

var childElements = parentElement.children;
var divs = [];

// Filter out only those children that are divs
for (var i = 0; i < childElements.length; i++) {
if (childElements[i].tagName === 'DIV') {
divs.push(childElements[i]);
}
}

var salesDiv = divs[3];

console.log(salesDiv);

var salesTable = salesDiv.getElementsByTagName('table')[0];

var rows = salesTable.rows;
console.log(rows);
var revenueCell = rows[13].cells[2];
var revenue = revenueCell.textContent;
revenue = revenue.replace('$', '');
revenue = revenue.replace(',', '');
console.log(Number(revenue))
var devRevenue = Number(revenue * 0.51);
var devRevenueString = numberWithCommas(Math.floor(devRevenue));

var newRow = salesTable.insertRow(14); // Insert after net

var nameElem = document.createElement('td');
var sumElem = document.createElement('td');
var spacerElem = document.createElement('td');
nameElem.innerHTML = '<b>Developer net revenue</b>';
sumElem.textContent = `$${devRevenueString}`
sumElem.setAttribute('align', 'right')
newRow.appendChild(nameElem);
newRow.appendChild(spacerElem);
newRow.appendChild(sumElem);

console.log("Steamworks Dev Net: Added sales for date range net");
}

console.log("Steamworks Dev Net: Begin");

addSummaryNetRow();
addSalesNetRow();
Binary file added icon-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"manifest_version": 3,
"name": "Steamworks Dev Chrome Extension",
"version": "1.0",
"permissions": [
"activeTab"
],
"content_scripts": [
{
"matches": ["https://partner.steampowered.com/app/details/*"],
"js": ["content_script.js"]
}
],
"background": {
},
"action": {
},
"icons": {
"16": "icon-16.png",
"48": "icon-48.png",
"128": "icon-128.png"
}
}

0 comments on commit 674241b

Please sign in to comment.