Last active
July 23, 2016 03:19
-
-
Save bastsoft/3060adb8bc121360f9a183e1470aa47d to your computer and use it in GitHub Desktop.
readability habrahabr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
btr.loadGist({ url: 'https://gist.github.com/', id: '3060adb8bc121360f9a183e1470aa47d'}, function(){ | |
btr.contextMenu('body', { | |
readability: btr.functionGist('readability.js') | |
}); | |
alert('done'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var title = document.querySelector('h1').innerText;//document.querySelectorAll('h1'); | |
window.articleBody = document.querySelector('.article__body') || document.querySelector('.content'); | |
window.articleBodyText = articleBody.innerText; | |
articleBodyText = '# ' + title + "\n\n" + articleBodyText; | |
window.articletitles = articleBody.querySelectorAll('div[field="title"]'); | |
articletitles = articletitles[0] ? articletitles : articleBody.querySelectorAll('h2'); | |
articletitles.forEach(function(titleDiv){ | |
articleBodyText = articleBodyText.replace(titleDiv.innerText, '## ' + titleDiv.innerText); | |
}); | |
articleBody.querySelectorAll('li').forEach(function(titleDiv){ | |
articleBodyText = articleBodyText.replace(titleDiv.innerText, '* ' + titleDiv.innerText); | |
}); | |
console.log(articleBodyText); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment