From 37cd49a51d6fbd95660d86ef13ad620d59f1320f Mon Sep 17 00:00:00 2001 From: Chris Hanel Date: Fri, 10 Sep 2021 11:46:25 -0700 Subject: [PATCH] updates to template --- content.js | 57 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/content.js b/content.js index b45c808..0413077 100644 --- a/content.js +++ b/content.js @@ -3,11 +3,15 @@ var scrapeEpisodeData=function(){ let linkCollect = new Array; let descriptionCollect = new String; let audioIntro = new String; + let audioIntroLink = new String; let audioOutro = new String; + let audioOutroLink = new String; let audioInter = new Array; + let audioInterLinks = new Array; let episodeTitle = new String; let episodeDate = new String; let clipboardText = new String; + let directLink = new String; //get episode Date let dateDiv = $('.postmeta').find('div').last(); @@ -20,14 +24,14 @@ var scrapeEpisodeData=function(){ let epLinkText = "*[" + window.location.href + " " + episodeTitle + "]\n" linkCollect.push(epLinkText); + //direct download to mp3 + directLink = $('.powerpress_link_d').attr('href'); + //cycle through post and grab data we care about $('.fullpostentry').find('p').each(function( index ) { let textChecker = $(this).text(); - console.log(typeof textChecker); - console.log(textChecker); if (index == 0 ) { - console.log("new description"); let descriptRaw = $(this).text(); if (descriptRaw.startsWith("\n", 0)) { descriptRaw = descriptRaw.substring(1); @@ -37,68 +41,86 @@ var scrapeEpisodeData=function(){ else if (textChecker.startsWith("Link", 1)) { $(this).find('a').each(function() { - console.log("new link"); let linkHref = $(this).attr('href'); let linkText = $(this).text(); let newLink = "*[" + linkHref + " " + linkText + "]\n" linkCollect.push(newLink); - console.log(newLink); }); } else if ( textChecker.startsWith("Audio", 0)) { let lines = textChecker.split("\n"); jQuery.each(lines, function( index ) { - console.log(this); if (index == 0) { audioIntro = this.substring(13); - console.log('new intro'); } //outro is always last one else if (index == lines.length - 1) { audioOutro = this.substring(13); - console.log('new outro'); } // interstitial if there's only one else if (lines.length < 4) { audioInter.push(this.substring(20)); - console.log('new interstitial'); } //interstitials when there's multiple else { audioInter.push(this.substring(22)); - console.log('new interstitial'); } }); } }); - clipboardText = "==Date==\n" + episodeDate + "\n\n==Summary==\n\'\'"; + $('.fullpostentry').find('strong').each(function( index ) { + + let strongText = $(this).text(); + let potentialLink = $(this).next('a'); + + console.log(strongText); + + if (strongText.startsWith("intr", 6)) { + console.log('intro'); + audioIntroLink = potentialLink.attr('href'); + } + + else if (strongText.startsWith("inte", 6)) { + audioInterLinks.push( potentialLink.attr('href')); + } + + else if (strongText.startsWith("outro", 6)) { + console.log('outro'); + audioOutroLink = potentialLink.attr('href'); + } + }); + + clipboardText = "{{#vardefine:downloadlink|" + directLink + "}}\n\n"; + clipboardText += "==Date==\n" + episodeDate + "\n\n==Summary==\n\'\'"; clipboardText += descriptionCollect + "\'\'\n\n"; clipboardText += "==Topics==\n* {List or summarize the main topics, noting " + "prominently mentioned players or teams and making internal " + "wiki links to them (even if those pages have not been created " + "yet).} \n\n==Intro==\n"; - clipboardText += audioIntro; + clipboardText += "[" + audioIntroLink + " "; + clipboardText += audioIntro + "]"; if (audioInter.length > 0) { let interHeader = audioInter.length > 1 ? "\n\n==Interstitials==\n" : "\n\n==Interstitial==\n"; clipboardText += interHeader; jQuery.each(audioInter, function( index ) { - clipboardText += this + "\n"; + clipboardText += "[" + audioInterLinks[index] + " "; + clipboardText += this + "]\n"; }); clipboardText += "\n"; } else { clipboardText += "\n\n"; } - clipboardText += "==Outro==\n" + audioOutro + "\n\n"; + clipboardText += "==Outro==\n[" + audioOutroLink + " " + audioOutro + "]\n\n"; clipboardText += "==Banter==\n{- If applicable.\n- For banter, note " + "prominent teams and players, and make internal links for " + "them.\n- Links and mentions do NOT have to be made for " + @@ -106,10 +128,11 @@ var scrapeEpisodeData=function(){ "==Email Questions==\n* {For EMAIL episodes: note the " + "question asker, transcribe the question, and link " + "prominent teams and players.}\n\n" + - "==Play Index or StatBlast==\n{For PLAY INDEX segment: " + - "transcribe the Play Index scenario that the host is trying " + + "==Stat Blast==\n{For STAT BLAST segment: " + + "transcribe the scenario that the host is trying " + "to answer (you do NOT have to transcribe the method used " + - "within the PI)}\n\n" + + "within the Stat Blast, but note its findings and andy other " + + "pertinent info.)}\n\n" + "==Notes==\n* {List noteworthy tangents, quotes, " + "highlights, miscellany not covered above.}\n\n" + "==Links==\n";