Makes directory index pages (either local or remote open directories) actually useful. Adds sidebar and content preview pane; keyboard navigation; sorting; light/dark UI; preview images/fonts in navigable grids; browse subdirectories w/o page reload (“tree view”); media playback, shuffle/loop options; basic playlist (m3u, extm3u) & cuesheet (.cue) support; create, edit, preview, save markdown/plain text files; open font files, view complete glyph repertoire, save glyphs as .svg; more.
< 脚本Supercharged Local Directory File Browser的反馈
Hello hacker09,
Thanks for your feedback.
If a browser can't play .avi files, the script won't enable it to do so. I'm not aware of any browsers that can play .avi; however, if your browser can, then you can add 'avi' to the list of video formats in the code, ca. line 145 (in the "$item_kind" object).
If the arrow keys don't seem to work, it is probably because the sidebar isn't focussed. If an image is focussed and zoomed, the arrow keys will move the image around. Use the escape key to focus the sidebar and then the arrow keys will work as expected. But perhaps I should make the arrows work if the image isn't zoomed...
Let me know if this helps, or if you have any other questions.
—Michael
You are welcome.
Then that's my bad. I don't know if the opera browser opens .avi videos or not, I just thought that this was your script bug...
The image wasn't focused and wasn't zoomed...
This is the error the browser displays
userscript.html?name=Supercharged%20Local%20Directory%20File%20Browser.user.js&id=a056b149-2bef-42b0-aadc-9e1b39e31aa0:2713 Uncaught TypeError: Cannot read property '3' of undefined
at showContent (userscript.html?name=Supercharged%20Local%20Directory%20File%20Browser.user.js&id=a056b149-2bef-42b0-aadc-9e1b39e31aa0:2713)
at clickRow (userscript.html?name=Supercharged%20Local%20Directory%20File%20Browser.user.js&id=a056b149-2bef-42b0-aadc-9e1b39e31aa0:3368)
at HTMLSpanElement.eval (userscript.html?name=Supercharged%20Local%20Directory%20File%20Browser.user.js&id=a056b149-2bef-42b0-aadc-9e1b39e31aa0:3105)
at HTMLElement.dispatch (userscript.html?name=Supercharged%20Local%20Directory%20File%20Browser.user.js&id=a056b149-2bef-42b0-aadc-9e1b39e31aa0:6)
at HTMLElement.r.handle (userscript.html?name=Supercharged%20Local%20Directory%20File%20Browser.user.js&id=a056b149-2bef-42b0-aadc-9e1b39e31aa0:6)
Hmm, although I have encountered similar errors during development, I am unable to reproduce this error now when I navigate folders with images in them.
What kind of image was it, and how many other images are in the folder? Do the file names/paths include any unusual characters? Does this happen in every folder you try?
They include only common characters... I doubt that the number of images in the folder and the kind of image has anything to do with this bug... It's most likely that an adventlistener or function isn't working properly...
Yes it doesn't work even thought I've moved the image to D:\\ and renamed the image to a.jpg...
Does arrow navigation work for other file types?
Which browser are you using?
And can I assume you're using Windows? Does the script work on your C:\ drive? (I don't have access to a Windows machine, so I can't do any testing.)
I wonder if this error is due to something unique to your system, because no one has reported anything similar.
What other file types does the arrow shows and works on? the arrows aren't displayed when I open an .pdf file...
Opera GX.
Yes you can! on my D:\\ drive
The theme settings aren't permant, please change this.
Thanks for the information. I've installed Opera GX on my Mac, installed Tampermonkey, and installed the script. It's working flawlessly for me, including the Prev/Next buttons which appear in the title bar for images and fonts. (I understand "arrow navigation" to mean using the arrow keys on the keyboard. Does arrow navigation work for you?)
Needless to say, this is a difficult problem to diagnose when I can't reproduce it on my machine.
The UI theme setting is permanent for me between page reloads and browser restarts. If you want new pages to always use the dark theme, you have to edit the user settings in the code. See ca. line 83: change theme: 'light'
to theme: 'dark'
. You'll have to do this whenever the script is updated as well.
Ah, this script doesn't use gm_set or local storage: security protocols don't permit scripts that work on local pages to set cookies or access local storage. This was a major problem in the early stages of the development of this script. The solution was to store defaults in the code and temporary user settings in the query string appended to the URL. The only way to have (semi-)permanent custom default settings is for the user to edit the default user settings in the code, beginning around line 48. (As I mentioned previously, these settings will be removed whenever the script is updated.)
Sorry, does arrow navigation work for you? Clicking the Prev/Next buttons next to the Reload button fires the left/right arrow navigation function, so knowing if arrow navigation does or does not work for you might help me to figure out what's going on.
Do you have any other scripts installed that might conflict with this one (though I can't imagine how)? Have you tried disabling all the other scripts to see if the problem goes away?
Also, have you tried this in any other browser?
lol, Really? I didn't know that... but gm_set isn't really "local storage" I think...
When I say "arrow navigation" I'm not talking about the keyboard arrow keys... No the print I sent you isn't working...
Ok, I will try tomorrow to use the keyboard keys.
I will try that too!
No, but I can also try tomorrow
The keyboard arrow navigation doesn't do anything for me either, but at least the console doesn't show any errors...
I do have other scripts that run on files, but I tried on edge and the keyboard arrows doesn't do anything, and the click arrows shows the same console error message. Also on edge chromium I've only your script installed...
You should add this rule to your script...
// @exclude *.pdf*
Now it's working on the edge and opera browser after I pressed esc...
You should somehow auto unfocus then...
Maybe you could use try/catch?
Can you confirm that you are running the latest version of the script — v 6.1.5?
Could you add this line at the end of code (before the closing line })();
):
$('button').on('mouseup','span',function(e) { $(this).blur(); });
Let me know if that does anything.
The script hasn't been tested at all on Edge, so errors are entirely possible.
Finally, what is the issue with pdfs?
Thanks.
Yes, I am running the latest version.
$('button').on('mouseup','span',function(e) { $(this).blur(); });
The issue with pdfs is that I prefer to have the browser open the pdf file than your script. Your script iframes the pdf, so the pdf can't be "full screen" (as big as the whole maxima4zied browser)
Could please add an icon to your script? (for better appearance)
That line code didn't do anything...
Sorry the code snippet didn't work. Could you please describe in detail and in sequence exactly what steps you take in order to cause the error to appear?
Also, you mentioned that after pressing esc
"it's working" — please explain what exactly it is that's working and what you were doing just before you tried that.
I'll @exclude *.pdf*
to the script in a future update (when [or if] we can get your problem figured out).
What do you mean about adding an icon to the script?
I just send you a video showing what I did
// @icon https://www.google.com/s2/favicons?domain=myanimelist.net
In your case is
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACAAgMAAAC+UIlYAAAACVBMVEUmRcmZzP8zmf8pVcWPAAAAAXRSTlMAQObYZgAAAFBJREFUeF7tyqERwDAMBEE3mX5UiqDmqwwziTPHjG7xrmzrLFtRaApDIRiKQlMYCsFQFJrCUAiGotAU5hTA1WB4fhkMBsOJwWAwgHvB8CHpBcTbpxy4RZNvAAAAAElFTkSuQmCC
Hi hacker09,
Thanks for making the video. It helped me to see a few things. I have a couple of thoughts.
I noticed that you had the sidebar hidden in the first examples when the buttons didn't work, but at the end, when they did, the sidebar was visible. Is that always the case? In other words, do the buttons fail (only?) when the sidebar is hidden and work when it is visible? (For me, they work fine in both situations.)
This is unrelated to your issue, but I noticed that both vertical and horizontal scrollbars appear in the sidebar, and that the vertical one is not the full height of the sidebar. Do the scrollbars always appear for you? They shouldn't, unless needed because of the length of the file list.
Meanwhile, I've been thinking more about your request to exclude .pdfs from the script. Perhaps I misunderstand your objective, but it seems to me that you can still "full screen" pdfs by hiding the sidebar. Is that not good enough? I like the idea of opening local files in browser directly from the Finder/Explorer and having the script automatically load it in its parent directory.
Thanks for the prod about adding a script icon (I'd though about adding an icon before, but never got around to it)
And thank you for sticking with me on this. I'm still not certain I fix the button issue, since I can't reproduce it, but I'll continue looking.
Michael
the sidebar doesn't matter.
Yes, they always appear, even when I've only 1 file in the folder.
Oh, you are right, You don't really need to exclude pdfs from your script, but I think that's it's a bit annoying to always need to click on the "hide" sidebar, just to hide your script sidebar every time that a pdf is opened, you could make the sidebar auto hide when any pdf is opened, instead of excluding pdfs of your script.
Thanks, good luck!
It's becoming annoying to use the script because the script removes the file link on the address bar, so if I bookmark the link or reopen/reload the tab the file doesn't open
Hi, are you saying that when you want to open a link to a *file*, the script opens up the containing *directory* instead so that you can't directly bookmark the file? Are you saying that you'd prefer to be able to open file links without the script loading? If so, this is a behavior that I could adjust as a pref setting; indeed, I believe that was the original behavior, but it made more sense to me to let the script handle both file and directory links.
Could you show me examples of a link you want to bookmark and the actual bookmark you get?
Thanks.
If I open this
file:///C:/Users/test.pdf
It becomes
file:///C:/Users/ when I reopen/reload or bookmark
so the test.pdf file is never opened...
Can you try this:
In the code, on line 16, replace
// @include file://*
with:
// @include file://*/
// @include file://*/?*
(Leave any other @includes as they are.)
This will make the script only open local directories, not files.
If you wanted to revert the script to open all local files and directories, just add back the original line:
// @include file://*
Alternately, in the script settings for your userscript manager (e.g., greasemonkey), you should be able to add custom include/exclude urls. You could play around with those settings to exclude files. (These include/exclude lines can use regex patterns, like * as a wildcard character.)
Let me know if this works for you.
It worked
Good to hear. Just remember that if you modified the code itself instead of using the manager settings you'll have to make the code modifications again when the script is updated.
I am working on a update now, in fact; if I have time, I might look into a way to toggle the file/directory behavior, or perhaps add something like an "alt-click" to open a file link in a new tab without it invoking the script (via a url query entry).
I've updated the script and readded
// @include file://*/?*
But now files are opened using the script again
OK, try these include rules, deleting any other file rules. Try adding these to the greasemonkey rules for this script, instead of adding them in the code itself; that way they will persist through updates.
// @include /^file://.*/$/
// @include /^file://.*/\?.*$/
Do I have to go to the script settings tampermonkey page and add to the include rules?
/^file://.*/$/
/^file://.*/\?.*$/
I did that and nothing changed
Try adding this rule to the "exclude" rules in the tampermonkey settings. I haven't tested this, but basically you don't want the script to work on any local file or directory, but only on directories; the two new rules should take care of that, and this new one should override the @include rule that is written in the code. You might not need "@include" or "@exclude" when adding the rules in the tampermonkey setting. If it doesn't work, try deleting the "file://*" rule from the code. I will add these rules in the next update, with instructions about how to exclude local files.
// @exclude file://*
Adding them directly on the code doesn't work either.
Send me prints, that would be much more helpful.
Upon further thought, it might not be possible to fully satisfy your request, because if files are excluded from the script, then you won't be preview them when browsing directories -- the preview pane will show the "loading" spinner instead. I *might* be able to figure out some kind of preference setting in the code to exclude files opened in a new tab from within a browsed directory, but it will be a little while before I can work on that.
Thanks, that worked.
Good luck with developing that.
Another solution for you, in case you don't know about it:
In Vivaldi (and possibly other browsers) you can right- or control-click on links and there will be a "Bookmark Link" item. If you use this method, you wouldn't need to disable the script from working on files and just create bookmarks from clicking links in the sidebar.
I also found this Chrome extension that seems to do the same thing:
https://chrome.google.com/webstore/detail/link-to-bookmark/mhdidjpeopgpmlknlinmkplhbgopjegj?hl=en-US
Thanks, bookmarking doesn't work and doesn't make an exception in the script.
Hmm, I don't understand your comment. In my browser — *Vivaldi* — I can right-click on links in the sidebar in order to get a popup menu that includes a "Bookmark Link" item, which does indeed bookmark the link to the file, not its containing directory. Other browsers may not have this capability natively (Chromium doesn't appear to), but it seems there are extensions that can provide it.
Both vivaldi and that extension seems to just bookmark the file as any browser would do, but I'm not sure.
I prefer to use custom settings than vivaldi or another extension do to the same thing I can do by modifying the settings, but thanks.
I thought bookmarking files was what you were looking to do? But whatever works for you.
True, that's what I'm doing, but I prefer to keep modifying your script till your improve it.
Thanks for the recommendations.
// @exclude file://* no longer works for me
Can you explain in more detail what the problem is? Thanks.
This solves my problem
// @exclude file:///*/*.*
It makes the script open folders, but the script does not run if I open a file directly on the browser (desired behavior). The thing is that it stops opening .txt files when the script is running...
Could you make an option to make it not run on files?
// @exclude file:///*/*.*
I am tired of adding this every update...
Why not simply add the URL to your user script manager's list of excluded sites for this script?
Thanks.I totally forgot about that.
Amazing!
But doesn't play .avi videos.
The arrow buttons to switch between images inside a folder doesn't work