GitHub-userscripts icon indicating copy to clipboard operation
GitHub-userscripts copied to clipboard

(GitHub table of contents) Resizable window

Open darkred opened this issue 4 years ago • 13 comments

Greetings @Mottie

It's a feature request I wanted to make for a long time now: it's about your awesome script, "GitHub table of contents".

Would it be possible to make its window resizable? i.e. to be able to drag its right corner(or its edges) and expand/reduce as I want?

The reason is that very often, many entries in the TOC don't fit in the window and are truncated, and I have to mouseover each line to see it fully.

Example page: https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_52.md

Screenshot

2021-01-29_003027

Thank you

P.S. I know you are super busy in your life, just wanted to express my wish 🙂

darkred avatar Jan 28 '21 22:01 darkred

Done 😸

Mottie avatar Jan 31 '21 12:01 Mottie

You are awesome!! Thanks so much !

darkred avatar Jan 31 '21 12:01 darkred

If it's not too much to ask, could you please make the sections collapsible when clicking the arrows ? e.g. in the following screenshot examples, the Workbench section to collapse when clicking the arrow before it? I am asking this, because when the TOC is very long, it would be very convenient to be able to expand/collapse some sections.

Screenshot 1

2021-01-31_164441

Screenshot 2

2021-01-31_165053

darkred avatar Jan 31 '21 14:01 darkred

Clicking on the arrows works for me in Chrome. What browser are you having an issue in?

Mottie avatar Jan 31 '21 21:01 Mottie

I hid my last comment: there are some issues after your last commit: the collapse arrows now work only on some pages, that's why I mistakenly thought that the feature is missing, sorry. So, this comment is an issue report:

Below are example pages: (tested in my Chrome 88 everyday profile, with latest TM beta 4.12.6126)

Where the collapse arrows don't work, having login to GitHub: (it's rather in all pages I tried) (I believe this started happening right after I resized the TOC window) https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_52.md https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_53.md https://github.com/sinatra/sinatra (the example URL) https://github.com/sindresorhus/refined-github https://github.com/Mottie/tablesorter

No generated TOC when not logged in to GitHub: https://github.com/sinatra/sinatra (the example URL) https://github.com/Mottie/GitHub-userscripts https://github.com/Mottie/tablesorter

There's the following error in Console in the last case group:

Uncaught (in promise) TypeError: Cannot read property 'parentElement' of null at init 

Also, when I test on a fresh Chrome profile with only latest Tampermonkey beta/Violentmonkey and the script (after login to GitHub): there are no collapse arrows: (no error in Console)

Screenshot

2021-01-31_235622

darkred avatar Jan 31 '21 21:01 darkred

Update: regarding my everyday Chrome profile, I found that the collapse arrows not working is a conflict with the Refined GitHub extension: when I disable it, then they work ok every time. If I enable it, then they don't work most of/all the times.

darkred avatar Jan 31 '21 22:01 darkred

I found that the collapse arrows event listener was being bound on every page refresh. I've updated the script just now. Please try it now.

Mottie avatar Jan 31 '21 22:01 Mottie

Thanks a lot! So, indeed the 1st issue is fixed!

What now still remains is the other two: (I retested them just now with a different fresh Chrome profile with only TM beta/VM beta)


No generated TOC when not logged in to GitHub: Example pages: https://github.com/sinatra/sinatra (the example URL) https://github.com/Mottie/GitHub-userscripts https://github.com/Mottie/tablesorter

There's the following error in Console:

Uncaught (in promise) TypeError: Cannot read property 'parentElement' of null at init 

No collapse arrows after login to GitHub: (no error in Console) Example page: https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_53.md

Screenshot

2021-01-31_235622

darkred avatar Jan 31 '21 22:01 darkred

Ok, I've just updated the userscript to work on the logged out header... I can't reproduce the last issue with no arrows. I did change how the arrows are rendered, so maybe it's incompatible with other browsers? No idea.

Mottie avatar Jan 31 '21 23:01 Mottie

Thanks for the fix when logged out.


The last issue occurs for me consistently.

If I may assist in reproducing it, here is my STR in full details:

In in a fresh Chrome profile of 88.0.4324.104 / Firefox 85 (win10 x64 20h2), with only Tampermonkey beta 4.12.6126/Violentmonkey beta 2.12.9.4 and the script:

I open https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_52.md : there are no collapse arrows in both browsers neither when logged in nor when logged out.

Screenshots:

logged out:

in Chrome

2021-02-01_172941

in Firefox

2021-02-01_171917

logged in:

in Chrome

2021-02-01_173042

in Firefox

2021-02-01_172034

  In both browsers also I tried changing the GitHub theme Dark/Light (https://github.com/settings/appearance) but it made no difference.

darkred avatar Feb 01 '21 13:02 darkred

Update: in the fresh profiles, the collapse arrows are displayed again only if I install (Stylus extension and the) Github Dark userstyle. Without that userstyle, the arrows don't appear in neither the Dark nor Light default GitHub theme.

darkred avatar Feb 01 '21 17:02 darkred

Oh, are they just invisible?

Mottie avatar Feb 02 '21 01:02 Mottie

Yes, exactly:

darkred avatar Feb 02 '21 11:02 darkred