joeytwiddle / code

All my old code in various languages. Some of it is better than the rest.
27 stars 6 forks source link

make TOC minimizable in offline html file #4

Open Konfekt opened 6 years ago

Konfekt commented 6 years ago

Regarding,

https://github.com/joeytwiddle/code/tree/master/other/gm_scripts/table_of_contents_everyw

could the TOC be made minimizable on offline HTML pages, that is, whose address isfile:///..., just as it is online HTML pages, that is, whose address is http://.. or https://...?

Konfekt commented 6 years ago

Thank you for this script. It is particularly helpful for navigating HTML compiled from markdown files (by pandoc --toc --from=markdown --to=html ...).

joeytwiddle commented 6 years ago

I'm glad you like the script! But what precisely is the problem?

  1. The TOC cannot be minimized when viewing an offline page
  2. The TOC can be minimized, but that state is forgotten when you open the next page

If the problem is number 2, I don't think we can remember the state in the file:// scheme. But I could add a boolean to the script. You could change the boolean from true to false so the TOC will be minimized be default. Would that be ok? (Are you able to edit the script you installed?)

Konfekt commented 6 years ago

Yes, it is curiously 1.. Yes, it would be nice to be minimized by default. Yes, I can edit it.

joeytwiddle commented 6 years ago

I am using Tampermonkey under Chrome. I added @include file://* to the script, and I also had to "Allow access to file URLs" in the extension's settings.

But after that it worked fine for me! What platform are you using?

Anyway the new version 1.0.4 lets you set startRolledUp = true at the top of the script. I hope that will work for you!

If not, please take a look in the console (Ctrl-Shift-J for Chrome, Ctrl-Shift-K for Firefox) and let me know if there are any red errors. Cheers!

Konfekt commented 6 years ago

I am using Firefox 52.8.0 (64 bits) with GreaseMonkey 3.17 and ToC EveryWhere 1.05 with startRolledUp = true. The consolse says

[TOCE] Adding fallback implementation of GM_set/getValue  Table_of_Contents_Everywhere.user.js:53:3
[TOCE] Error! HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy  Table_of_Contents_Everywhere.user.js:53:3
Konfekt commented 6 years ago

Well, under the latest Firefox 60 the same problem with the latest Greasemonkey.