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 > 25942;
}).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 contributorString = null;
let contributor = await fetch(revisionUrl)
.then((response) => response?.text() || "")
.then((html) => html.match(/Patch by\s*:\s*[^@]*@*(?<nick>[^><]+).*/g));
if (contributor === null)
contributorString = committer;
else {
contributorString = contributor[0].replace(/Patch by\s*:\s*[^@]*@*(?<nick>[^><]+).*/g, "$1");
}
return {
"contributor": contributorString,
"commitNumber": commitNumber,
"contributed": contributor !== null,
"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,
"contributed": x.contributed,
"revisionUrl": x.revisionUrl
});
return rv;
}, {});
var div = document.createElement("div");
div.id = "summary-output";
var sortedContributorNames = Object.keys(a).filter(b => b != "autobuild");
sortedContributorNames.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
div.innerHTML = sortedContributorNames.map(contributorName => {
let contributorData = a[contributorName];
let string = `<strong>${contributorName}</strong> ${(contributorData[0].contributed ? "contributed" : "committed")}:\n<ul>`
string += contributorData.map(commit => `<li>${commit.commitNumber} <a href="${commit.revisionUrl}">${commit.revisionTitle}</a><li>`).join("");
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
Stan edited the content of this paste. (Show Details)Dec 20 2021, 2:30 PM