Giter Site home page Giter Site logo

Comments (1)

natevw avatar natevw commented on June 19, 2024

This project does not appear to be open source licensed so I hesitate to make a public copy of it and submit a PR. But since the source is available in case it helps others, the following patch may be of interest:

diff --git a/src/bookmarklet.js b/src/bookmarklet.js
index ae3becf..1c2ea5d 100644
--- a/src/bookmarklet.js
+++ b/src/bookmarklet.js
@@ -113,7 +113,8 @@ function getOutline() {
   for (var i = 0; i < els.length; i++) {
     var el = els[i];
     var visible = isVisible(els[i]);
-    var n = parseInt((el.getAttribute('role') == 'heading' && el.getAttribute('aria-level')) || el.nodeName.substr(1));
+    var n = getHeadingLevel(el);
+    if (n === null) continue;
     if (visible) {
       var wrongLevel = n > previousLevel && n !== (previousLevel + 1);
       previousLevel = n;
@@ -207,6 +208,11 @@ function isVisuallyHidden(el) {
   }
 }
 
+function getHeadingLevel(el) {
+  var role = el.getAttribute('role') || 'heading',
+      level = parseInt(el.getAttribute('aria-level') || el.nodeName.substr(1))
+  return (role === 'heading') ? level : null;
+}
 
 
 function highlightElement(el, disableAutoScroll) {

Building requires an older version of node, e.g. in a VM you might:

# install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
. ~/.bashrc

# use NVM to install old node.js
nvm install 8

# use old nodejs to build project
npm install && npm start

The updated bookmarklet can then be found in the docs/index.html page.

from h123.

Related Issues (4)

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.