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

blendora

v2.0.0

Published

Blendora: Seamlessly integrate custom components into popular web apps. Simplify DOM manipulation and enhance API interaction for a cohesive user experience. Ideal for extensions and web devs.

Downloads

5

Readme

Blendora

Blendora is a powerful TypeScript library designed to streamline the integration of custom components into widely-used web applications such as YouTube, Facebook, Instagram, and more. It excels in harmoniously blending your web components with the existing design, simplifying DOM manipulation, and elevating browser API interaction. This empowers developers to concentrate on scripting while achieving a cohesive and polished user experience. Blendora is the ideal tool for browser extension creators and web developers seeking to enhance the functionality and aesthetics of their web applications.

Installation

To use Blendora in your project, simply install it via npm:

npm install blendora

Features

YouTube DOM Manipulation

Blendora provides a set of functions for manipulating the DOM of YouTube web pages.

createPanelHeader(customHeader: CustomPanelHeader): HTMLDivElement

This function creates a custom header for YouTube player menus.

  • customHeader: An object containing customization options for the header. The object should have properties like panelId, panelClass, btnLabel, btnOnClick, panelTitle, panelOptions, and options.

Example usage:

import { createPanelHeader } from 'blendora';

const customHeader = {
  panelId: 'custom-panel',
  panelClass: 'custom-panel-class',
  btnLabel: 'Back',
  btnOnClick: (event) => { /* Custom event handler */ },
  panelTitle: 'Custom Panel Title',
  panelOptions: {
    optionsTitle: 'Options',
    optionsOnClick: (event) => { /* Custom event handler */ }
  },
  options: (panelHeaderElement) => { /* Customize options container */ }
};

const panelHeader = createPanelHeader(customHeader);

createMenuItem(customItem: CustomMenuItem): HTMLDivElement

This function creates a custom menu item for YouTube player menus.

  • customItem: An object containing customization options for the menu item. The object should have properties like itemId, itemClass, hasAriaPopUp, hasAriaChecked, itemRole, itemTabIndex, itemIconPath, itemLabel, itemContent, itemOnClick, and options.

Example usage:

import { createMenuItem } from 'blendora';

const customItem = {
  itemId: 'custom-item',
  itemClass: 'custom-item-class',
  hasAriaPopUp: 'menu',
  itemRole: 'menuitem',
  itemTabIndex: '0',
  itemIconPath: 'M12 3L17 17H7L12 3Z',
  itemLabel: 'Custom Menu Item',
  itemOnClick: (event) => { /* Custom event handler */ },
  options: (menuItemElement) => { /* Customize options container */ }
};

const menuItem = createMenuItem(customItem);

createMetadataSection(customMetadataSection: CustomMetadataSection): HTMLDivElement

This function creates a custom metadata section in the metadata action bar on YouTube.

  • customMetadataSection: An object containing customization options for the metadata section. The object should have properties like sectionId, sectionClass, headerIcon, headerTitle, items, and options.

Example usage:

import { createMetadataSection } from 'blendora';

const customMetadataSection = {
  sectionId: 'custom-metadata-section',
  sectionClass: 'custom-metadata-section-class',
  headerIcon: 'path/to/icon.svg',
  headerTitle: 'Custom Metadata Section',
  items: [ /* Array of section items */ ],
  options: (metadataSectionElement) => { /* Customize section wrapper */ }
};

const customMetadataSectionElement = createMetadataSection(customMetadataSection);

createSectionItem(customSectionItem: CustomSectionItem): HTMLDivElement

This function creates a custom section item for use within other Blendora functions.

  • customSectionItem: An object containing customization options for the section item. The object should have properties like id, className, children, and options.

Example usage:

import { createSectionItem } from 'blendora';

const customSectionItem = {
  id: 'custom-section-item',
  className: 'custom-section-item-class',
  children: [ /* Array of child elements */ ],
  options: (sectionItemElement) => { /* Customize section item */ }
};

const sectionItemElement = createSectionItem(customSectionItem);

Picture-in-Picture Mode

Blendora provides a function for toggling the Picture-in-Picture mode for the primary video element.

togglePictureInPictureMode(): Promise<void>

This function toggles the Picture-in-Picture mode for the primary video element. If the primary video is already in Picture-in-Picture mode, it will exit the mode. If the primary video is not in Picture-in-Picture mode, it will request to enter the mode.

Example usage:

import togglePictureInPictureMode from 'blendora';

await togglePictureInPictureMode();

VideoPlayer Class

The VideoPlayer class provides a set of methods to manipulate HTML video elements, allowing you to control playback speed, current time, and seek through video content.

constructor(videoElement: HTMLVideoElement)

  • videoElement: The HTMLVideoElement associated with the player.

Example usage:

import VideoPlayer from 'blendora';

const videoElement = document.getElementById('myVideo');
const videoPlayer = new VideoPlayer(videoElement);

getPlaybackSpeed(): number

This method retrieves the current playback speed of the video.

Returns:

  • number: The current playback speed.

Example usage:

const playbackSpeed = videoPlayer.getPlaybackSpeed();
console.log(`Current Playback Speed: ${playbackSpeed}`);

setPlaybackSpeed(speed: number): { status: 'SUCCESS' | 'ERROR', response: string }

This method sets the playback speed of the video.

  • speed: The desired playback speed.

Returns:

  • { status: 'SUCCESS' | 'ERROR', response: string }: An object indicating the status of the operation. If successful, it returns 'SUCCESS' and a response message. If the speed value is invalid, it returns 'ERROR' and an error message.

Example usage:

const result = videoPlayer.setPlaybackSpeed(2.0);
if (result.status === 'SUCCESS') {
  console.log(result.response);
} else {
  console.error(result.response);
}

getCurrentTime(): number

This method retrieves the current playback time of the video in seconds.

Returns:

  • number: The current playback time in seconds.

Example usage:

const currentTime = videoPlayer.getCurrentTime();
console.log(`Current Time: ${currentTime} seconds`);

setCurrentTime(seconds: number): { status: 'SUCCESS' | 'ERROR', response: string }

This method sets the current playback time of the video to the specified time in seconds.

  • seconds: The desired playback time in seconds.

Returns:

  • { status: 'SUCCESS' | 'ERROR', response: string }: An object indicating the status of the operation. If successful, it returns 'SUCCESS' and a response message. If the time value is invalid, it returns 'ERROR' and an error message.

Example usage:

const result = videoPlayer.setCurrentTime(30);
if (result.status === 'SUCCESS') {
  console.log(result.response);
} else {
  console.error(result.response);
}

getDuration(): number

This method retrieves the total duration of the video in seconds.

Returns:

  • number: The total duration of the video in seconds.

Example usage:

const duration = videoPlayer.getDuration();
console.log(`Video Duration: ${duration} seconds`);

seekCurrentTime(direction: 'forward' | 'backward', seconds: number): { status: 'SUCCESS' | 'ERROR', response: string }

This method seeks the current playback time of the video in the specified direction (forward or backward) by the specified number of seconds.

  • direction: The direction to seek, either 'forward' or 'backward'.
  • seconds: The number of seconds to seek.

Returns:

  • { status: 'SUCCESS' | 'ERROR', response: string }: An object indicating the status of the operation. If successful, it returns 'SUCCESS' and a response message. If the direction or time value is invalid, it returns 'ERROR' and an error message.

Example usage:

const result = videoPlayer.seekCurrentTime('forward', 10);
if (result.status === 'SUCCESS') {
  console.log(result.response);
} else {
  console.error(result.response);
}

### YouTube Player (YTPlayer)

Blendora offers a YTPlayer class that extends the VideoPlayer class and is specialized for YouTube video manipulation.

#### `YTPlayer(videoElement: HTMLVideoElement, data: YTPlayerData)`

This class extends the VideoPlayer and allows you to work with YouTube-specific video player features.

- `videoElement`: The HTMLVideoElement associated with the player.
- `data`: An object containing YouTube-specific data, such as `videoID`.

Example usage:

```javascript
import YTPlayer from 'blendora';

const videoElement = document.getElementById('myVideo');
const data = {
  videoID: 'youtube-video-id',
};

const youtubePlayer = new YTPlayer(videoElement, data);

console.log(`Video ID: ${youtubePlayer.videoID}`);

License

Blendora is released under the MIT License.

Contributing

Contributions are welcome! Please follow our contribution guidelines.

Authors