Skip to content

Commit

Permalink
Merge pull request #10 from oldnewthing/straighten-quotes
Browse files Browse the repository at this point in the history
Straighten quotes, ignore promotional banner when looking for description
  • Loading branch information
chrishanel authored Apr 24, 2022
2 parents d0d8789 + 03e6c95 commit 1ef6bb3
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions content.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
var scrapeEpisodeData=function(){

function straightenQuotes(s) {
return s.replace(/[\u2018\u2019]/g, "'").replace(/[\u201c\u201d]/g, '"');
}

let linkCollect = new Array;
let descriptionCollect = new String;
let audioIntro = new String;
Expand All @@ -20,7 +24,7 @@ var scrapeEpisodeData=function(){

//episode link
let titleDiv = $('.posttitle').first();
episodeTitle = titleDiv.text();
episodeTitle = straightenQuotes(titleDiv.text());
let epLinkText = "*[" + window.location.href + " " + episodeTitle + "]\n"
linkCollect.push(epLinkText);

Expand All @@ -30,23 +34,23 @@ var scrapeEpisodeData=function(){
directLink = $('.powerpress_link_d').attr('href');

//cycle through post and grab data we care about
$('.fullpostentry').find('p').each(function( index ) {
$('.fullpostentry').children('p').each(function( index ) {
let textChecker = $(this).text();

if (index == 0 ) {
let descriptRaw = $(this).text();
if (descriptRaw.startsWith("\n", 0)) {
descriptRaw = descriptRaw.substring(1);
}
descriptionCollect = descriptRaw;
descriptionCollect = straightenQuotes(descriptRaw);
}

else if (textChecker.startsWith("Link", 1)) {
$(this).find('a').each(function() {
let linkHref = $(this).attr('href');
let linkText = $(this).text();

let newLink = "*[" + linkHref + " " + linkText + "]\n"
let newLink = "*[" + linkHref + " " + straightenQuotes(linkText) + "]\n"

linkCollect.push(newLink);
});
Expand All @@ -56,7 +60,7 @@ var scrapeEpisodeData=function(){
let lines = textChecker.split("\n");
lines.every(function(line) {
var lower = line.toLowerCase();
var data = line.substring(line.indexOf(":") + 2);
var data = straightenQuotes(line.substring(line.indexOf(":") + 2));
if (lower.includes("intro")) {
audioIntro = data;
}
Expand Down

0 comments on commit 1ef6bb3

Please sign in to comment.