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

electron-extended-webextensions

v0.0.10

Published

Extend the built-in functionality of Electron Web Extensions with additional features commonly used by browsers.

Downloads

47

Readme

electron-extended-WebExtensions

Extend the built-in functionality of Electron Web Extensions with additional features commonly used by browsers.

Application APIs

Here's what you need to use in order to integrate this module

const { ExtendedExtensions } = require('electron-extended-WebExtensions')

// Pass in an Electron `Session` object you wish to attach to.
// If you're not sure, use the default one `session.defaultSession`
const extensions = new ExtendedExtensions(session, {
  // Handle when the system expects a new tab to be created
  // `popup` is set to `true` when it's a popup for a browser action
  // `openerTabId` is set to the id of the parent tab (if applicable)
  // You should return an Electron WebContents instance so it can be tracked
  onCreateTab: async ({url, popup=false, openerTabId}) => WebContents,
})

// Pass an absolute path to load an extension
// This will also attach necessary injected APIs to it
const extension = await extension.loadExtension(path)

// You can unload an extension at runtime by passing it's id
await extensions.unloadExtensions(extension.id)

// Listen for context menu events and get the list of menu items to add
webContents.on('context-menu', (event, params) => {
  const extensionMenuItems = extensions.contextMenus.getForEvent(webContents, event, params)
  // You might want to add some of your own context menu items
  // Could be useful in combination with https://github.com/sindresorhus/electron-context-menu
  Menu.buildFromTemplate(extensionMenuItems).popup()
})

// When you set up browser windows, you'll likely want to render browser actions
extensions.browserActions.list()

// Extensions may set custom browser actions for a tab
// You can fetch the tab-specific actions with this:
extensions.browserActions.list(webContents.id)

// Browser Action objects look something like this:
const action = {
  // Track this to notify the system of clicks
  extensionId,
  extensionURL,
  // Disabled items aren't usually listed
  enabled: true,
  // This text is usually displayed as image alt text upon hovering
  title,
  // This is the popup URL if one exists
  // Mostly handled internally by the system
  popup,
  // This is the "badge text", it can get update periodically
  text: '0',
  // This is the icon you should render for the browser action
  icon: 'chrome-extension://idhere/image.png',
}

// When users click on the Browser Action UI, notify the system with this:
// The `webcontents.id` should be the id of the web contents that the click was performed for (the active tab)
extensions.browserActions.click(extensionId, webContents.id)

TODO

Items with a question mark might not happen or are low priority

  • Try to reuse the Electron Extensions API
  • Manifestv2
  • Support APIs used by WebRecorder
  • [x] Support background pages
    • [x] Spawn background page
    • [x] Provide extension APIs to it
      • [x] Tabs
      • [x] Debugger
      • [x] Context Menu
      • [x] Browser Action
      • [x] webRequest (doesn't work on custom protocols yet, built in)
  • [x] Support content scripts
    • [x] Run content scripts (doesn't work on custom protocols yet, built in)
    • [x] Provide extension APIs
      • runtime.connect and friends
  • [ ] Support popup APIs
  • [x] Support BrowserActions
    • [x] Ability to specify BrowserAction in manifest
    • [x] List browser actions from electron app, listen for triggers
    • [x] Send browser action event to background page
    • [x] Open link on browser action
    • [ ] chrome.browserAction.setBackgroundColor
  • [x] contextMenu API
    • [x] create()
    • [x] update()
    • [x] remove()
    • [x] onClicked()
    • [ ] Support url patterns for filtering (todo)
  • [x] webNavigation API
    • [x] onBeoreNavigate
    • [x] onCommitted
    • [x] onDOMContentLoaded
    • [x] onCompleted
    • [x] onErrorOccured
    • [x] getFrame()
    • [x] getAllFrames()
    • [ ] Support url patterns for filtering (todo)
    • historyStateUpdated/createdNavigationTarget,referenceFragment will be TODO
  • [ ] Extend Tabs API:
    • [x] Built in support has sendMessage, reload, executeScript, update
    • [x] get, query, create, remove
    • [x] onActivated/onCreated/onRemoved/onUpdated
    • [x] executeScript got overrided in order to support custom protocols (for Agregore)
    • captureTab?
    • insertCSS / removeCSS?
    • getCurrent?
    • goBack/goForward?
  • [x] Support debugger API needed by WebRecorder
  • [ ] Support interacting with pages using Custom Protocols Handlers
  • [ ] Notifications API? https://www.electronjs.org/docs/latest/api/notification
  • Other APIs? Open an issue or a PR.