Page MenuHomeWildfire Games
Paste P239

Phab commit list to text scrapper
ActivePublic

Authored by Stan on Jan 30 2021, 2:08 PM.
var a = (await Promise.all(Array.from($(".phui-oi-list-view").children).filter(li =>
{
let tableElement = li.children[0].children[0].children[0].children[0].children[0].children;
let commitNumber = tableElement[1].children[0].children[0].innerText;
commitNumber = +commitNumber.substring(2);
return commitNumber > 25016;
}).map(async (li) =>
{
let tableElement = li.children[0].children[0].children[0].children[0].children[0].children;
let commitNumber = tableElement[1].children[0].children[0].innerText;
let revisionTitle = tableElement[1].children[0].children[1].innerText;
let committer = tableElement[2].children[1].children[0].children[0].text;
let revisionUrl = "https://code.wildfiregames.com/" + commitNumber;
let contributor = await fetch(revisionUrl).then((response) => response.text()).then((html) => html.match(/Patch by\s*:\s*(?:(?!<br>).*)/g))
if(contributor == null)
contributor = committer;
else
{
contributor = contributor[0].replace(/.*@([^<]*).*/,"$1");
contributor = contributor.replace(/.*:\s*([^<]*).*/,"$1");
}
return {
"contributor": contributor,
"commitNumber": commitNumber,
"revisionTitle": revisionTitle,
"revisionUrl": "https://code.wildfiregames.com/" + commitNumber,
}
}))).reduce(function (rv, x)
{
(rv[x.contributor] = rv[x.contributor] || []).push({
"revisionTitle": x.revisionTitle,
"commitNumber": x.commitNumber,
"revisionUrl": x.revisionUrl
});
return rv;
}, {});
var div = document.createElement("div");
sortedContributorNames = Object.keys(a).filter(b => b != "autobuild");
sortedContributorNames.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
div.innerHTML = sortedContributorNames.map(contributorName =>
{
var contributorData = a[contributorName];
var string = `<strong>${contributorName}</strong> committed:\n<ul>`
for (let commit of contributorData)
{
string += `<li>${commit.commitNumber} <a href="${commit.revisionUrl}">${commit.revisionTitle}</a><li>`
}
string += `</ul>`
return string;
}).join("<br/>");
document.getElementById("main-page-frame").prepend(div);

Event Timeline

Stan created this paste.Jan 30 2021, 2:08 PM
Stan created this object with visibility "Public (No Login Required)".
Stan edited the content of this paste. (Show Details)Mar 2 2021, 5:28 PM
Stan edited the content of this paste. (Show Details)Mar 29 2021, 1:55 PM