Skip to content

Commit

Permalink
Fix player possessives, and improve hyperlink detection
Browse files Browse the repository at this point in the history
FanGraphs will sometimes include the apostrophe inside the hyperlink,
resulting in a wikilink like "[[Joey Gallo']]s foot". We move it
outside, resulting in "[[Joey Gallo]]'s foot".

Support hyperlinks to old FanGraphs player pages, and hunt down links
a little better.
  • Loading branch information
oldnewthing committed Jul 30, 2022
1 parent 2fa7082 commit f0d2eed
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ var scrapeEpisodeData=function(){
var copy = node.cloneNode(true);
// Wikify all the links
$(copy).find('a').each(function (index) {
if (this.href.startsWith("https://www.fangraphs.com/players/")) {
if (this.href.startsWith("https://www.fangraphs.com/players/") ||
this.href.startsWith("http://www.fangraphs.com/statss.aspx?playerid=")) {
this.insertAdjacentText("beforebegin", "[[");
this.insertAdjacentText("afterend", "]]");
} else {
Expand All @@ -23,7 +24,9 @@ var scrapeEpisodeData=function(){
this.insertAdjacentText("beforebegin", "''");
this.insertAdjacentText("afterend", "''");
});
return straightenQuotes($(copy).text());
var result = straightenQuotes($(copy).text());
result = result.replace(/']]/g, "]]'");
return result;
}

let linkCollect = new Array;
Expand Down Expand Up @@ -78,7 +81,7 @@ var scrapeEpisodeData=function(){
}
}

else if (textChecker.startsWith("Link", 1)) {
else if (textChecker.startsWith("Link", 1) || textChecker.startsWith("Link", 0)) {
let lines = wikify(this).split("\n");
lines.forEach(function(line) {
line && linkCollect.push("*" + line + "\n");
Expand Down

0 comments on commit f0d2eed

Please sign in to comment.