Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
frmacdonald committed Sep 5, 2019
1 parent d90fc2c commit 7047d6f
Show file tree
Hide file tree
Showing 3 changed files with 202 additions and 90 deletions.
29 changes: 8 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,41 +173,28 @@ const articleParser = async function (options, socket) {
// Title
article.title.text = await getTitle(dom.window.document)

let content = '';

// Twitter Content
if ( article.host === 'twitter.com' ) {
let content = ''

if (article.host === 'twitter.com') { // Twitter Content
// Tweet
content = await page.evaluate(() => {
const j = window.$

j('.permalink-tweet-container .js-tweet-text-container .twitter-timeline-link').remove();
j('.permalink-tweet-container .js-tweet-text-container .twitter-timeline-link').remove()

return j('.permalink-tweet-container .js-tweet-text-container').html();
return j('.permalink-tweet-container .js-tweet-text-container').html()
})

}
// Youtube Content
else if ( article.host === 'www.youtube.com' ) {

} else if (article.host === 'www.youtube.com') { // Youtube Content
// Video Title
article.title.text = await page.evaluate(() => {
const j = window.$

return window["ytInitialData"].contents.twoColumnWatchNextResults.results.results.contents[0].videoPrimaryInfoRenderer.title.runs[0].text
return window.ytInitialData.contents.twoColumnWatchNextResults.results.results.contents[0].videoPrimaryInfoRenderer.title.runs[0].text
})

// Video Description
content = await page.evaluate(() => {
const j = window.$

return window["ytInitialData"].contents.twoColumnWatchNextResults.results.results.contents[1].videoSecondaryInfoRenderer.description.runs[0].text
return window.ytInitialData.contents.twoColumnWatchNextResults.results.results.contents[1].videoSecondaryInfoRenderer.description.runs[0].text
})

}
// General Content
else {
} else { // General Content
content = helpers.grabArticle(dom.window.document).innerHTML
}

Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const parser = require('./index.js')
const fs = require('fs')

const options = {
url: 'https://www.youtube.com/watch?v=rYNNsDR6fD0',
//enabled: ['lighthouse', 'screenshot', 'links', 'sentiment', 'entities', 'spelling', 'keywords']
url: 'https://www.facebook.com/theSNP/posts/10157713206314078?__xts__[0]=68.ARBoNpoPePPidcVdwLUUTldfnZ4am0mpQcRttEc7CODxbTPJwM2FxPNouEiKBFnIpFkwhNXuqWbQjY-GuFbgJYpexlJT_fT49-upAdjVh5knQwOWPpKwVCKYFq93feZ4N-pcY5Z9PZJ-V13ivZDo3N0LmKrB7KyeU2D9Q6zyYUDIvWZFHvFyOgImmXJdVX5Blya4ZfttMhTRuEfo8Gbgl4PAtBu4M55fIb7t42HTGz8UD1BcLYz54dqShBKe9hUn9fhV_ARlB9kSwGHTIqfXgqfZJ9KT8TPVULIX8kOK8CqUzs47k05dSjQ_aEE65anM2IjGGLEnW36Vtuq44ZIXPDTbN6XZcCrGMtLAERgJ42ZlhICOOM15sBObTXMFWykcB4jp7e-eDiV19skDCRWxcOsdb4KKSjnVG679cTPki8oZcY9nFgtxhzQcIMlDlmGEfLJY6jAaoyK9yYd9QpnfepkZsYj81HblAmRXUdoaecHDn-uHsgqGiMHArFoO76w&__tn__=C-R',
// enabled: ['lighthouse', 'screenshot', 'links', 'sentiment', 'entities', 'spelling', 'keywords']
enabled: ['links', 'sentiment', 'entities', 'spelling', 'keywords']
}

Expand Down
Loading

0 comments on commit 7047d6f

Please sign in to comment.