${text}
- ${includesHtml} - ` - } - - const tweetUrl = ` - — ${ - author.username - } ${ - author.name - } ${formatTimestamp(tweetData.created_at)} - ` - - const content = ` - - - - - - - - - - - - tags
- // in the body.
- isPaywalledContent(document: Document): boolean {
- return document.getElementsByClassName('paywall').length > 0
- }
-
- removeNonArticleNodes(document: Document): Document {
- const genericCallouts = Array.from(
- document.querySelectorAll('[data-testid="GenericCallout"]'),
- )
- const ads = Array.from(document.querySelectorAll('.ad__slot')).map(
- (it) => it.parentElement,
- )
- const mostPopularArticles = Array.from(
- document.querySelectorAll('[data-most-popular-id]'),
- )
-
- ;[...genericCallouts, ...ads, ...mostPopularArticles].forEach(
- (it) => it?.remove(),
- )
-
- return document
- }
-
- shouldPreHandle(url: string): boolean {
- const u = new URL(url)
- return u.hostname.endsWith('wired.com')
- }
-
- async preHandle(url: string): Promise
- {text}
- 问题: ${votes} vote${
- votes === '1' ? '' : 's'
- }
${question.innerHTML}`
- }
- }
- return newQuestion
- }
-
- parseComments(element: Element) {
- const dom = element.ownerDocument
- const newComments = dom.createElement('div')
-
- // comments
- const commentsDiv = element.querySelector(`.comments`)
- if (commentsDiv) {
- const comments = commentsDiv.querySelectorAll(`.comment`)
- if (comments.length > 0) {
- newComments.innerHTML = `Comments
`
-
- comments.forEach((comment) => {
- const author = comment.querySelector(`.comment-user`)
- const text = comment.querySelector(`.comment-copy`)?.textContent
- const authorHref = author?.getAttribute('href')
- const date = comment.querySelector(`.relativetime-clean`)?.textContent
- if (author && text && authorHref && date) {
- const newComment = dom.createElement('p')
- newComment.innerHTML = `${author.innerHTML}: ${text} - ${date}`
- newComments.appendChild(newComment)
- }
- })
- }
- }
-
- return newComments
- }
-
- parseAuthors(element: Element) {
- const dom = element.ownerDocument
- const newAuthors = dom.createElement('div')
-
- const authors = element.querySelectorAll(`.post-signature`)
- authors.forEach((author) => {
- const isOwner = author.classList.contains('owner')
- const name = author.querySelector(`.user-details a`)?.textContent
- const link = author.querySelector(`.user-details a`)?.getAttribute('href')
- const reputation = author.querySelector(`.reputation-score`)?.textContent
- const badges = Array.from(
- author.querySelectorAll(`span[title*='badges']`),
- )
- .map((badge) => badge.getAttribute('title'))
- .join(', ')
- const date = author.querySelector(`.user-action-time`)?.textContent
- if (name && link && reputation && date) {
- const newAuthor = dom.createElement('p')
- newAuthor.innerHTML = `${name} - ${reputation} reputation - ${
- badges || 'no badge'
- } - ${date}`
- if (isOwner) {
- const author = dom.createElement('span')
- author.setAttribute('rel', 'author')
- author.innerHTML = name
- newAuthor.appendChild(author)
- }
- newAuthors.appendChild(newAuthor)
- }
- })
-
- return newAuthors
- }
-
- shouldPreParse(url: string, dom: Document): boolean {
- return new URL(url).hostname.endsWith('zhihu.com')
- }
-
- async preParse(url: string, dom: Document): PromiseWelcome
-
- {type}
-
-
- {title}
-
-
- {author}
-
- Dashboard
-