npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

thread-reader-reader

v0.1.0

Published

Parse Twitter thread already simplified by third-party Thread Reader app, and produce dead simple HTML.

Downloads

9

Readme

Thread-reader-reader

Helps converting Twitter threads to stand-alone articles by extracting them to simple HTML. Relies on the Thread reader third-party app.

Installation

  1. Make sure you have Node and NPM installed.
  2. Install the command globally
    npm i -g thread-reader-reader

Usage

  1. Submit the first tweet of a Twitter thread to Thread reader

  2. Get the resulting URL (Should look like https://threadreaderapp.com/thread/1241364682084093953.html)

  3. Run the CLI program with the following command:

    thread-reader-reader <thread_reader_url>
  4. The result will be written to the standard output.

Tweets will be output in <p> divs, and images and videos will be wrapped in a <figure> tag following the paragraph of the tweet they appear in.

Downloading resources

By default, original image and video urls will be kept, meaning links will still use the resources stored on Twitter servers.

Instead, you can download these resources locally by adding a path to a local directory as second parameter.

thread-reader-reader <thread_reader_url> [directory_to_store_files]

In that case, the urls to images and videos will be rewritten with the same path as relative url, replacing Twitter urls.

You can change this relative url by specifying a third parameter.

thread-reader-reader <thread_reader_url> [directory_to_store_files] [relative_url_path]

That way, it's easy to adapt to how your destination website stores content.

Full example

Command:

thread-reader-reader https://threadreaderapp.com/thread/1241364682084093953.html aquatint-files /public/images/aquatint-files > aquatint-article.html

Result:

  • The extracted thread HTML will be written to the aquatint-article.html file.
  • In this HTML, urls to images and videos will use /public/images/aquatint-files as prefix.
  • Image and video files will be downloaded and stored in the aquatint-files directory, ready to be uploaded on your server, in the directory corresponding to /public/images/aquatint-files.

As a lib

You can also use the parser.js file as a separate lib.

The getTweets function takes a DOM element as input (JSDom or real DOM will work), basically the document of a Thread Reader page and will return an array of objects:

{
    tweetHTML,  // inner markup of the tweet text, including links 
    images,     // array of { url } objects
    videos      // array of { poster, sources: [{ type, src }] } objects
}