@imborge/twitter-dom
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

twitter-dom

This package provides a simple way for content scripts to get the nodes containing tweets on Twitter.com.

It provides a single class StatusObserver that you instantiate with a callback function that gets called when new tweet statuses are added to the DOM.

StatusObserver has only 2 methods:

observe() and disconnect which starts and stops listening to the DOM respectively.

Installation (via NPM)

npm install @imborge/twitter-dom --save

Sample usage

Make promoted tweets have a gray background:

import { StatusObserver } from "@imborge/twitter-dom";

const observer = new StatusObserver((statusNode, statusID, username) => {
  // statusID and username is extracted from links inside
  // status wrapper elements.
  
  // Promoted tweets don't have links containing
  // the status id of the tweet.
  if (!statusID) {
    statusNode.style.background = "rgba(0, 0, 0, .1)";
  }
});

observer.observe();

Package Sidebar

Install

npm i @imborge/twitter-dom

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

8.89 kB

Total Files

5

Last publish

Collaborators

  • imborge