Closed PetrK39 closed 1 year ago
Wow, you've fixed so many undocumented bugs that it makes me feel guilty for not bothering to mention any of them anywhere. I can confirm that infinite scroll, collapsible sidebar, thumbnails are working on Tampermonkey 4.17.6161 for Firefox.
Also noticed that the tags in the additional .txt file from FastDL were missing their newlines (e.g. post id 7724955
downloaded a text file with artist:smile (qd4nsvik)series:originalmeta:highresblue skycablecloudcloudy skyfantasyglowinglandscapelight particlesmoonno humansoceanreflectionreflective watersceneryshadowskystar (sky)starry skysunrisetowertree
), while doing the same on Chrome kept the newlines.
I was able to get the newlines to work in Firefox by changing line 1206 from elem.href = "data:text," + text;
to elem.href = "data:text," + encodeURIComponent(text);
—but I'm not sure if this would break other stuff.
In regards to complexity, what do you think about splitting things into separate files and using a bunch of @require's?
There is also a rare bug where when loading the next page with infinite scrolling, the content is added twice Have you experienced this? And it seems that the "load" event does not firing on GIF images, causing them to stay animated after "background" loading in the preview
Breaking up the script into separate files would be a great idea Especially separate large independent modules like ConfigManager, advanced blacklist and theme manager But, this would require me to learn more about JavaScript and meanwhile, I want to implement basic functionality
Note that (almost) all settings are css values, and, for example, you can use gradients/images/rgb,hsv, etc. in any combination as the background color for the minimized sidebar This also means that instead of values in pixels you can use vw, vh, em, %, and any other css units. I plan to extend this to light/dark theme customization
and yes, css injections work, but I think I'll leave it as it is, I just need to add validation
Note to self: in incognito mode it actually pretty fast check cache clearing, item search speed
Speedup might be from indexdb getting stored in memory rather than on-disk in your browser's incognito mode.
Also, I can't figure out history.pushState It doesn't work until I open any post manually. however, even so, behaviour of the history is far from expected
I'm unfamiliar with history.pushState and modifying browser history, but apparently the "unused"
parameter that's being fed htmlDocument.title
is nonstandard and deprecated. Not sure what the intended behavior is.
Also, regarding the navbar crash on the issue tracker and homepage, should we support the different navbar format at the expense of the CSS being different? (see pending review for a screenshot) Or do we just want to skip inserting the configuration button entirely and not bother?
Yes, there are several situations where the script breaks the page. Unfortunately, I don't have enough time right now to sit down and put everything back in order.
About browser history. I can confirm that it is a bug in Google Chrome as I have now checked it on Mozzila Firefox and everything works exactly as expected
the script is significantly struggle when working with a massive blacklistlist in addition to a large number of posts
It looks like we can't optimize the blacklist any further. The checkPost
function has a complexity of O(post count * blacklist entries count), which results in 16464 comparisons for 392 entries per page[^1]
Since not all tags in my general blacklist belong to gelbooru I need to add an ignore list for tag namespaces
The saddest part is that there is still a delay between loading posts and hiding them. This can probably be fixed by using the magic of lazy
[^1]: It takes up to 2 seconds to apply the whole blacklist to 10 pages, which to me is acceptable
The blacklist now works fast enough for infinite scrolling But the namespaces for the tags are lost Trying to make mass api queries leads to a lot of net errors
Since they are only used when downloading an additional tag file by RMB, they will only be resolved there, in a stable slow way
I have an idea: Add feature to *star* some tags and pin them on top of the autocompletion list But this would require to copy and modify a copyrighted code Do we need this feature in the main branch? For myself, I'm mostly browse gelbooru for one tag
I don't know much about software licensing, but it doesn't seem to be a big deal if we change it.
I think the pinning feature is totally fine to have in the main branch. I'm planning on adding Hydrus integration whenever I have free time, so I'm lenient about cutting things for being "bloat". The only line I'll draw is on importing an external library (e.g. jquery, underscore, etc.)
For the Danbooru code, we should add something like this to the LICENSE file:
The externally maintained libraries used by GelbooruOverhaul are:
- Autocomplete.js, located at danbooru/danbooru/app/javascript/src/javascripts/autocomplete.js, is licensed as follows:
"""
Copyright (c) 2013~2021, Danbooru Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
"""
Speaking of licensing, I just realized that GelbooruOverhaul doesn't have a license at the moment and is still All Rights Reserved. What license do you think this project should have? Personally, I don't really care whether the license is copyleft or permissive, but you have contributed 99.9% of the code so I'm interested in what you think.
I don't care too. Even though there is only my code, I probably would never have started a project like this if I hadn't seen your project. For integration with Hydrus I'm using Hydrus Companion. And since GelbooruOverhaul aims only at one site I don't see any reason to just copy Hudrus Companion features. But that doesn't mean we can't improve their interaction. But obviously, I didn't manage to work out the architecture for the script on the fly. You can see how much of a problem this is.
Alright, I'm very sorry for being deathly inactive and stonewalling this fantastic PR with my muteness. I'm just going to straight-up merge the changes you have made--remaining issues with lazy loading and infinite scrolling--for the sake of merging them (and doing a little housekeeping) because it has been several months and either this will never be merged or the refactor will need a refactor.
Basically I finished refactoring, only a few key features and a final cleanup are left
Later I will add info on the internals and how to add new featuresPlease make sure everything works correctly in all your usecases (You can now configure them via the Overhaul dialog in the top bar, including without reloading the page.)Adding new preferences
gelbooru-overhaul.configManager.js
getDefaultConfig()
It returns the following config objectWhere string is Key Where PreferenceCategory is
{ name: string, items: {string, PreferenceItem} }
The keys can be any string, but I prefer to keep the category structure
Category1.Item1
,Category1.Item2
,Category2.Item1
Preference value can be accessed using
Adding new features
gelbooru-overhaul.user.js
main()
Where listener is
which will be caused by the change of preference value and on page load If your setting is only used as a value in another function, there is no need to track its change The listeners should be arranged so that any of your preference tweak can be turned off and the page can be restored to its original appearance
You also may want to check
currentPageType
fromutils.pageTypes
If your preference sets css variables, see
applyCssVariableGoCollapseSidebar()
for example on how to do it If your preference has dependent preferences seeapplyTweakEnlargeOnHover()
for exampleYou can access page's thumbnails with
utils.getThumbnails()
which returnsHTMLImageElement[]
(posts for Gallery page, 'More Like This' for Post page)Config window automatically display your new preference but there is no validation and fool proof yet Note that values updates live
For thumbnail tweaks on Gallery page there is also
infiniteScrolling.addUpdateListener(listener)
Where listener isShould be applied only for new thumbs
Script starts on DOM ready so there is no need to check this
I don't urge you to take the pool requester right now, but don't forget to replace
@resource css
with your repository There are many improvements to the original script, something that was impossible before now works fine. You can check out the commit comments