Donmai

[Userscript] RecentTagsCalc

Posted under General

RecentTagsCalc replaces the current recent tags calculated by Danbooru for the tag edit form on uploads/posts. The default settings were designed to emulate the original functionality of recent tags before October 2018. The tags are calculated from both uploads and post edits, after the edit form has been submitted.

Installation

Project page
Main script
Usage notes

The tag list on the edit form works exactly the same as before. Also, the script calculates tags in the background automatically. Please note that this does not occur on tag edits that occur from the post index using the tag script or edit functions.

Tags can be pinned so that they always appear on every page load. This is done by clicking the oval icon next to a tag in the Recent tags list, which will change the oval to solid. To unpin a tag, click the oval icon next to the tag so that the oval icon is empty.

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

Final

Future additions:

  • Order by tag usage
    • Similar to Danbooru's current method
    • However usage calculations will be user controlled
  • Have choice for fallback sort when two tags evaluate the same
    • Such as two tags having the same category for category sort...
    • ...or two tags having the same post count for post count sort

Any suggestions or feedback is appreciated.

Latest edits

  • (2022-09-04) Updated script link in OP

Versions

Show
  • (2018-12-31)
    • Version 2 - Initial release
  • (2019-01-09)
    • Version 3 - Cache frequent tags
      • Fix tab synchronization and concurrency
      • Rebase and standardize the code
  • (2019-01-20)
    • Version 4 - Add category sort
      • Use form order when post counts are equal (for post order sort)
  • (2019-02-02)
    • Version 5 - Tags can be pinned
      • Added the multiple-type tag list
      • Added cache editor
  • (2019-02-15)
    • Version 6 Updated to newest library
  • (2019-12-28)
    • Version 7 Updated library version
  • Verified working on Firefox
  • Added extra usage notes

Updated

Pushed Version 3 which primarily adds the ability to cache the frequent/favorite tags, as well as fixing several minor issues such as concurrency and synchronization between tabs.

The caching of frequent tags was added as it was noticed that the frequent tags was taking about 1.5 seconds to load each time the new upload or post edit forms were opened. This also had the effect of causing the recent tags to take the same amount of time since it waits for Danbooru to add those columns before updating them. With the option of caching frequent tags turned on though (it is turned on by default), it can load those tags as soon as it gains execution.

The expiration time on updating the cached frequent tags is currently set at one week, although a control has been added to the user settings which allows for them to be manually updated if needed.

Minor versions
  • (2019-01-13)
    • 3.1
      • Remove unnecessary network calls when frequent tags are cached
      • Added compatibility with IndexedAutocomplete

Updated

Pushed Version 4 which adds the ability to sort new recent tags by tag category.

It was also sorting alphabetically for post count sort when the post counts were equal, but that was changed to use form order instead.

Minor versions
  • (2019-01-28)
    • 4.1
      • Fixed issue with how data was being broadcast
      • Only affected other tabs that were also on the user settings page

Updated

Pushed Version 5 which adds the ability to pin recent tags, which is done by clicking the circle icons next to the tags so that a pin icon appears. To unpin a tag, reverse the process by clicking the pin icon until the circle icon appears.

Additionally, the multiple tag lists option has been enabled, along with a setting to control the amount of tag groups. To help identify a group better, it also labels each group as the Nth upload or edit.

Finally, the cache editor being prototyped (forum #154196, forum #154240, forum #154285, forum #154332) was added. It's pretty much finalized by this point, so the code will be migrated and standardized across all scripts at the next library update.

Minor versions
  • (2019-02-08)
    • 5.1 - Fixed pinned tags not being checked on a page refresh

Updated

Pushed Version 6 which primarily integrates the new library code that was finalized earlier this week. This is coming out as a major version since a large majority of the code was changed while updating to the new library version and standardizing all of the affected userscripts.

Additionally, all of the menus were standardized, and fully working cache editors were incorporated. Also, a new control was added under cache settings which shows the size of all the userscript data amongst all of the various data storage.

Minor versions
  • (2019-02-16)
    • 6.1 - Fixed bug with incorrect function name on uploads page
  • (2019-05-19)
    • 6.2
      • Made use of "only" parameter
      • Fixed link binding for manual tags refresh
    • 6.3 - Fix network function not working without ID

Updated

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

  • Additions
    • Add 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
    • Settings menu now adapts to the color changes of the chosen theme (light/dark)
  • Fixes
    • Alter how tags are checked on a new tab to avoid having default tag categories
    • Fix the width of sort items on the settings menu
  • Other
    • Multiple internal code changes and refactors

It appears that Form Order now includes implied tags in the Recent category. Before it didn't do that; it just included tags that were just inputted by hand and just those tags. Is this a new function or a bug?

tapnek said:

It appears that Form Order now includes implied tags in the Recent category. Before it didn't do that; it just included tags that were just inputted by hand and just those tags. Is this a new function or a bug?

Sorry for the delay, I was waiting to try it out on an upload, and then got distracted. Anyways, I've tried it out recently, for instance on post #4377345 with the tag magazine cover, and it did not add the implication of cover to the list of recent tags.

What browser are you using? What version of the script are you using? Also, what are your script settings? The following are mine for reference, which I got by using the Cache editor on the right-hand side, selecting "Local storage" as a source, "user-settings" as the value, and then clicking the "Get" button.

User settings
{
  "uploads_order": [
    "form_order"
  ],
  "post_edits_order": [
    "form_order"
  ],
  "maximum_tags": 25,
  "include_metatags": true,
  "include_unchanged_tags": false,
  "include_removed_tags": true,
  "list_type": [
    "multiple"
  ],
  "metatags_first": false,
  "aliases_first": true,
  "include_deleted_tags": false,
  "cache_frequent_tags": true,
  "category_order": [
    "copyright",
    "character",
    "general",
    "artist",
    "meta",
    "alias",
    "metatag"
  ],
  "maximum_tag_groups": 5
}

Also, can you outline the steps taken in order to reproduce the result?

Script version was 7.10. Data source is IndexedDB. I was using Waterfox Classic, but I'm gonna try again on the latest version of Firefox to make sure it isn't because I was using an old browser.

My Settings
{
  "uploads_order": [
    "form_order"
  ],
  "post_edits_order": [
    "alphabetic"
  ],
  "metatags_first": true,
  "aliases_first": true,
  "category_order": [
    "general",
    "artist",
    "copyright",
    "character",
    "meta",
    "alias",
    "metatag"
  ],
  "list_type": [
    "queue"
  ],
  "maximum_tags": 30,
  "maximum_tag_groups": 5,
  "include_metatags": false,
  "include_unchanged_tags": false,
  "include_removed_tags": false,
  "include_deleted_tags": false,
  "cache_frequent_tags": false
}

edit: Weird. The script actually slows down the tab to a halt after an upload. If I stop the process Firefox is warning me about (i.e. the script), the script doesn't work and the Recent tags reverts to the default.

Updated

The script's not even working for me now. I purged the cache, too. Here's what I did.

1. Use the upload page to upload, not the bookmarklet.
2. Input everything needed for the upload: tags, rating, source.
3. Submit the upload.

Hopefully, other people aren't going through the same problems.

I just pushed Version 7.11 to the master branch which fixes a couple issues in general and also with the recent site update.

https://raw.githubusercontent.com/BrokenEagle/JavaScripts/master/recenttagscalc.user.js

I was testing it out using the exact same settings as you, and everything seems to be working okay. Let me know if you're still experiencing problems.

For reference, it still doesn't use the same style as the recent Danbooru deployment, though that's not as pressing for me to fix.

1