Code Monkey home page Code Monkey logo

accessibility-tree-visualizer's Introduction

Accessibility tree visualizer

A simple React application that reads Chrome’s Accessibility Tree and visualizes it as a web page.

It can serve as a quick way to preview how VoiceOver might read your website.

Disclaimer: This is just a proof-of-concept I did in a single night, so you will see very bad code inside. Moreover, the resulting webpage is not accessible at all.

How to use

  1. Obtain the Accessibility Tree of a website using Puppeteer with this script.

    // get-ax-tree.js
    const puppeteer = require('puppeteer')
    
    ;(async () => {
      const browser = await puppeteer.launch()
      const page = await browser.newPage()
      await page.goto(process.argv[2])
      const client =
        /** @type {import('puppeteer-core').CDPSession} */ (page._client)
      try {
        console.log(
          JSON.stringify(
            await client.send('Accessibility.getFullAXTree'),
            null,
            2,
          ),
        )
      } catch (e) {
        console.error(e)
        process.exitCode = 1
      } finally {
        browser.close()
      }
    })()

    Usage:

    node get-ax-tree https://github.com/ > tree.json
    
  2. Drag the JSON file into the webpage at https://codesandbox.io/embed/github/dtinth/accessibility-tree-visualizer/tree/master/?fontsize=14&hidenavigation=1&theme=dark&view=preview.

    (Also: If you have your JSON tree copied into clipboard, you can paste it into the webpage and it will load the tree from the clipboard.)

Development

I use CodeSandbox to develop this. Click this link to begin hacking: https://codesandbox.io/s/github/dtinth/accessibility-tree-visualizer

accessibility-tree-visualizer's People

Contributors

dtinth avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jaffamonkey

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.