Skip to content

Commit

Permalink
Merge pull request #14 from oldnewthing/apostrophes
Browse files Browse the repository at this point in the history
Fix player possessives, and improve hyperlink detection
  • Loading branch information
chrishanel authored Aug 2, 2022
2 parents 2fa7082 + f0d2eed commit 39efeca
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 39efeca

Please sign in to comment.