Danbooru

[Userscript] BetterSavedSearches

Posted under General

BetterSavedSearches provides an alternative mechanism and user interface for a user's saved searches. This includes more frequent checking, better feedback information, and finer control.

Installation

Project page

Main script

https://raw.githubusercontent.com/BrokenEagle/JavaScripts/stable/bettersavedsearches.user.js

Usage notes

Settings can be modified from your Danbooru user edit page, (My Account >> Settings) under Userscript Menus.

In the settings menu is a user setting to turn off the script, allowing it to be turned on/off on a subdomain basis.

Program details

Final

Current follow-up items are:

  • Have a query recheck based upon query velocity, i.e. how many average posts get added based on time. ***DONE***
  • Do a semi or full query reset/recheck if it's been more than X days (like 7), as otherwise it could take quite a while to reload. ***DONE***
  • Have only the label a query was clicked under be expanded on page reload, in the case that queries have more than one label. ***DONE***
  • Investigate using favorite groups an an alternative to the id: metatag to overome length limitations. ***UNNEEDED***

Any suggestions or feedback is appreciated.

Latest edits

  • (2020-01-01)
    • Version 6 Updated library version

Versions

Updated

Really wanted to use this but the version of greasemonkey I'm stuck using can't use it. I debugged it and found it's the async/await that causes it to fail. I can remove those and get it to mostly compile but don't know what I can do for removing the promises, as I haven't worked with those yet.

EMUltra3 said:

Really wanted to use this but the version of greasemonkey I'm stuck using can't use it. I debugged it and found it's the async/await that causes it to fail. I can remove those and get it to mostly compile but don't know what I can do for removing the promises, as I haven't worked with those yet.

What version of GreaseMonkey, what browser, and what OS are you using?

I'm not sure what I'll be able to do, since the code fundamentally relies on async/await and would require a major rewrite otherwise, but I'll look around and see if there's a way to get GreaseMonkey to use async/await.

Um...nevermind, I thought Pale Moon wasn't going to support async/await but the most recent update did. Got it working.

I just have one question though: Is there any settings to append the search query? I usually filter out my favorites and include status:any.

Edit: It causes small load hickups on every page load. Maybe Chrome doesn't get those. I just changed the whitelist to saved_searches and tags=search*.

Updated

EMUltra3 said:

I just have one question though: Is there any settings to append the search query? I usually filter out my favorites and include status:any.

Do you mean filter them out pre-collection or post-collection?

Pre-collection

If it's the former, then status:any is already being applied, as all posts are searched when they are created. One caveat is that if you haven't checked Danbooru for 3 or more days, then the script will have to play catch-up, and currently it doesn't look like the script is applying a status:any to the script. I'll have to check to see if the status:any is a freebie tag or whether it counts towards the user's total, and fix it accordingly.

For favorite filters, fav: currently falls under the list of metatags that aren't being handled by the regular handler.

Current unhandled metatags:

commenter, comm, noter, noteupdater, artcomm, ordpool, favgroup, fav, ordfav, md5, locked, width, height, mpixels, ratio, score, favcount, filesize, source, id, date, age, order, limit, approver, tagcount, pixiv_id, pixiv, search, upvote, downvote, flagger, appealer, gentags, chartags, copytags, arttags, metatags

When a query with an unhandled metatag is encountered, it switches to checking that query every 16-24 hours.

However, fav: could be handled, however it would be limited to just the user themselves. Also, many of the above entries could be handled, but I didn't want to put a lot of coding into it if there wasn't a desire for them.

Post-collection

I know that the search query line gets pretty long when checking a saved search, but you can always append status:any and/or -fav:username to the front of it.

If this is something that is desired on a permanent basis, then that would require a user setting and setting up a user interface.

Final

It'd probably be preferable to go with a post-collection filter for the fav: metatag, as the regular check happens every 5 minutes, and unless you are super fast at favoriting new posts, it wouldn't remove them from the post display. If the permanent option is desired, then it would take about a week to code.

Oh you don't worry about it, I just have it append the href in post-collection. Works great otherwise.

Pushed Version 3 which added several updates and enhancements:

  • Added user settings and a settings menu
    • (My Account >> Settings) under Userscript Menus
    • Includes a user setting to disable the script
    • Useful for only wanting the script to run on certain subdomains
  • Facilitate full pagination of saved searches
    • Beforehand it was limited to the 500 most recent
  • Facilitate sequential navigation of saved searches
  • Displays the current progress of the script on getting new posts
  • Provides a control to skip all progress to the present
    • Useful for long periods of absence
  • Added post filters <EMUltra3 forum #151420>
    • Can filter out favorited posts
    • Can automatically adds status:any to the search (to show deleted posts)
  • Accounts for user limit of tag on search queries
  • Updated the library to the latest version
  • Several other updates/simplifications
Minor versions
  • (2019-06-06)
    • 3.1 - Fix active query not being set correctly on a search label click

Updated

Pushed Version 4 which primarily adds the ability to view BetterSavedSearch results from the user profile page. Choose either "Script" or "Both" for the profile thumb source from the user settings menu.

Additionally, it adds a more robust method of handling pagination/sequentialization, including when opening a thumbnail/page link into a new tab.

Pushed Version 5 which primarily fixes a number of inefficiencies with the old random recheck mechanism. Instead of relying only on seed time, it now uses both post velocity and success rate. Additionally, the script now tracks the random recheck mechanism and lists them as Seeds/day on the post index menu. This will allow users to better tweak the recheck interval based upon their browsing pattern. Also, both the last seed time and last post found time are available for each query to help track how current they are.

Other major fixes and updates
  • Use scalpel instead of hammer validation for the query data
    • Beforehand it would throw out all of the data if any part was wrong
    • This would cause everything to be reset and would generate a large number of network requests
  • Heartbeat mechanism to detect when the browser discards the tab
    • This was causing tabs to unknowingly miss query updates from other tabs
    • When the tab became active again, it would often clobber the new data with its old data
  • Faster validation for arrays of simple data
  • Faster sets functions for simple boolean checks

Pushed Version 9 which primarily includes an update to the library code plus a few additions and fixes:

  • Additions
    • Added control on settings menu to reset all query data
    • Added new menu library elements/functions for cache editor
      • The raw program data can be extracted using the cache editor, which facilitates transferring program data to another browser/domain
      • Controls which are not applicable are hidden, for example Local storage must be selected before the raw data option becomes visible
  • Changes
    • The unseen posts control (# in parentheses) is now separate from the other controls and always visible
    • Altered method of retrieving aliases to reduce delay/load
    • Settings menu now adapts to the color changes of the chosen theme (light/dark)
  • Fixes
    • Fixed queries not updating once the maximum number of posts (200) had been reached
  • Other
    • Adjusted the CSS styling of several elements
    • Multiple internal code changes and refactors
  • 1