Danbooru

[Userscript] New Twitter Image Searches and Stuff

Posted under General

New Twitter Image Searches and Stuff (NTISAS) searches the Danbooru database for tweet IDs, adds image search links, highlights images based on Tweet favorites, and provides a variety of additional user interface enhancements.

It works with the new layout that Twitter has recently released (July 2019). It is based off the idea of the popular userscript Pixiv Image Searches and Stuff (PISAS, About:Userscripts).

Installation

Project page
Main script
Manual install

If there is difficulty connecting to the server to get the tweet database, then it can be downloaded and manually installed using one of the following links.

Info
  • Version: 53065849
  • Timestamp: 2024-01-13T02:45:06Z
Links
Updates

The script is based upon the previous version of TISAS which worked with the old version of Twitter (topic #15976).

Usage notes

https://github.com/BrokenEagle/JavaScripts/wiki/Twitter-Image-Searches-and-Stuff

Final

Any suggestions or feedback is appreciated.

Latest edits

  • (2024-02-08)
    • Updated Tweet DB version and manual install links in OP
  • (2024-04-12)
    • Version 9 Support new grid media timeline

Versions

Show
  • (2019-09-17)
    • Version 2 Initial release
  • (2019-10-15)
    • Version 3
      • Merge results with new query
      • User setting for minimum similarity cutoff (IQDB/SauceNAO)
      • User setting for displaying a Twitter user's ID
      • Additional click area for links
  • (2019-11-21)
    • Version 4
      • User setting to show image number when hovering over image
      • User setting for the maximum number of results for IQDB/SauceNAO
      • User setting to bypass checking the Tweet Database server
  • (2019-12-22)
    • Version 5 Updated library version
      • Several additions/improvements on settings menu
  • (2020-03-04)
    • Version 6 Added tweet views
      • Added ability to lock page navigation
      • Fixed uploader names not appearing on posts
  • (2020-12-25)
    • Version 7 View images at their native/large sizes
      • Added profile/timeline views
      • Display sauce remaining
      • Revamped the side menu
  • (2023-04-17)
    • Version 8 Revamped tweet menu
      • Show/hide side menu
      • Download links on timeline views
      • Removed several settings
    • Updated the wiki page
  • (2024-04-12)
    • Version 9 Support new grid media timeline

Updated

Pushed Version 3 which has several additions and fixes:

  • Additions:
    • Ability to merge results by running a new query
    • User setting for the minimum similarity cutoff on IQDB/SauceNAO
    • User setting to display a Twitter user's ID on the Tweet view
    • Additional clickable areas around the links <fredgido - Discord>
  • Changes:
    • Added types of data being exported to the Export Data filename
    • Account for items that Danbooru Member-level user's can't do (i.e. more than 2 tags for post queries)
  • Fixes:
    • Fixed spacing of Twitter menu items being occasionally unchanged
    • Fixed anchor hashmarks "#" in the URL causing page detection to fail
    • Fixed tweet statistics incorrectly resetting when going to the Tweet view and back
  • Other:
    • Updated external code library versions
    • Several other code refactors and minor fixes

Updated

Pushed Version 4 which has several additions and fixes:

  • Additions:
    • User setting to display the image number when hovering over an image
      • Mostly useful for when using the Download Original function
    • User setting for the maximum number of results to return for IQDB/SauceNAO
    • User setting to bypass checking the Tweet Database server
      • Mostly useful if the server is unreachable from your browser/device/location
  • Fixes:
    • Fixed image menu being doubled up or not there at all for some retweets <fredgido - Discord>
    • Fixed Tweet videos not being processed when autoplay was enabled <fredgido - Discord>
    • Fixed Tweet videos/GIFs sometimes not being playable <fredgido - Discord>
    • Fixed Tweet video images not being downloadable <fredgido - Discord>
    • Fixed Tweet cards and quoted tweets being incorrectly processed
    • Fixed post tooltips not being added in some cases
    • Fixed status markers not being positioned correclty

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

  • Changes
    • Altered how IQDB/Sauce check save data to avoid saving unnecessary information
      • This fixes the image menu sometimes stalling when loading new tweets
  • Fixes
    • Fix popup text in IQDB/Post advanced tooltips causing the tooltips to disappear
  • Other
    • Multiple internal code changes and refactors

Pushed Version 6 which primarily includes adding tweet views.

  • Additions:
    • Added ability to track tweet views
      • Only tweets with media are tracked
      • Tweets are only counted once per page load
      • Tweets with previous views can be highlighted
        • With a control in the side menu
        • This shows up as rounded rectangle on the left side of a tweet
      • Tweet views currently expire after one month if they are not renewed
    • Added ability to lock page navigation
      • This blocks navigating to external links and page reloads/unloads
      • This does not block regular Twitter navigation
    • Added setting to show/hide network error count
      • As shown in the side menu
  • Changes:
    • Grouped storage and network calls for better efficiency
      • Pending requests are sent as a group at tenth second intervals
    • Created static anchor points for the tweet status bar
      • This guarantees the order of elements appearing there
  • Fixes:
    • Uploader names not appearing on the post tooltips
    • Tweet indicators not rendering in some cases
    • Status bar was not rendering correctly on main tweets in some cases
  • Other:
    • Added additional unhandled image URLs
      • This keeps the image menu from being added to the wrong tweets
    • Additional refactoring and relocating of code
      • Both for better grouping and to fix some minor issues

I'm getting an error looking through any tweet as of late. The error I get reads "Error marking up stream tweet!".
Downgrading to an older version of this script has the same problem.

Debug console shows a lot of net::ERR_NAME_NOT_RESOLVED connection errors.

AkenoA said:

I'm getting an error looking through any tweet as of late. The error I get reads "Error marking up stream tweet!".
Downgrading to an older version of this script has the same problem.

Yeah, that's to let me know when Twitter changes their page structure, since the script is very dependent on a stable structure. I've been working on an update to the script, but have had several other items that have also kept me busy. Regardless, I'll try to have what I've got cleaned up and pushed out by tomorrow. You can disable the script until then so that you don't keep getting those error messages.

Debug console shows a lot of net::ERR_NAME_NOT_RESOLVED connection errors.

Those have nothing to do with the script. It does the same thing even with all userscripts disabled. I'm thinking it might have to do with an extension, but as it doesn't have a lot to do with my scripts, I'm not really invested in finding about something that I can't really affect anyways.

Pushed Version 7 which includes:

  • Additions:
    • Added setting to view images at their native size
      • Main menu >> Function >> image_popout_enabled
      • Hovering over an image activates this
      • Clicking the popup image displays the :large version
      • Clicking again switches to Twitter's version of photo display
      • (Limited to only the timeline views)
    • Added setting for profile/timeline views
      • Main menu >> Display >> display_profile_views
      • This will show the last time that you visited a user or one of their timelines
      • The expiration for these views is 1 year
    • Added setting to show the remaining sauce count
      • Main Menu >> Display >> display_available_sauce
      • Shows up in the Side Menu underneath the Info section
      • This only gets populated if you use one of the sauce links
      • The data for this expires after an hour if not updated
    • Added ability to show the current list sizes
      • Main Menu >> List >> "List info"
  • Changes:
    • Revamped the side menu
      • Split it into 3 sections which allows for more room
      • The hotkeys Alt+1, Alt+2, Alt+3 switches between them
    • Added a download counter for downloading originals
      • Provides feedback on how many downloads are currently in progress
      • Beforehand there could be up to several seconds without any indication
    • Query storage/network calls as soon as Tweet IDs are known
      • So there should be less delay waiting for items to display when scrolling
  • Other:
    • Updated to the Library Version 13 code
    • Fixed several style issues with eslint
    • Save all storage/network requests for debugging

FunkyJustin said:

I'm getting an error

HTTP 999:Bad error code!
Failed to connect to remote server to get latest database info!

Any way to fix this?

Same. You can enable "Bypass server mode" in Settings -> Database in the meanwhile.

Since the thread is already bumped I might as well ask here: @BrokenEagle98, is there a reason why highlights and autoclick IQDB should only work on the media timeline? For logged-out users only the main user timeline is accessible, a logged-in user could have several artists in a Twitter List, in both cases those would be helpful.

FunkyJustin said:

I'm getting an error

HTTP 999:Bad error code!
Failed to connect to remote server to get latest database info!

I'm not sure what steps you are taking to get that error. If you're trying to upgrade/install the DB, then I just tested both and it works fine for me.

Nameless_Contributor said:

Since the thread is already bumped I might as well ask here: @BrokenEagle98, is there a reason why highlights and autoclick IQDB should only work on the media timeline? For logged-out users only the main user timeline is accessible, a logged-in user could have several artists in a Twitter List, in both cases those would be helpful.

For the highlights, they are a comparison against a single standard, namely a single artist. If you start comparing multiple accounts, then it is inevitable that one or more artists' tweets will always take the top position, and the same being true for the bottom position. All that tells someone is that some artists are more popular than others, and nothing else really. Since the main timeline can include retweets from other accounts, that one is excluded as well. However, you may not have known, but even logged out users can still access the media timeline by using the search timeline, using at least the following search parameters from:SOMEGUY filter:media , replacing SOMEGUY with the name of the artist's Twitter account.

As to the autoclick IQDB, it is an extremely costly operation having to ping the Danbooru server for every single image on every single tweet, so I limited it to only the media timeline. This one wouldn't have the same cons as mentioned above for the Twitter lists though, so it could be added to that I suppose. I wouldn't add it to the main or the likes timeline though, since they more likely have junk images show up on those and thus a wasted IQDB query.

Edit:

Forgot to mention, but the autoclick IQDB is also currently available on the search timeline using the same search parameters as mentioned above.

Also, for the bad error code, check that you are not blocking Google Drive, which is where I'm storing the DB files. You can test it out using the following link.

https://drive.google.com/file/d/1evAJM-K6QpHg52997PbXf-bptImLgHDs/view

Updated

BrokenEagle98 said:

autoclick IQDB is also currently available on the search timeline using the same search parameters as mentioned above.

Thanks for the info. I feel very stupid for not realizing that from reading the IsMediaTimeline() function.

The error turned out to be because of my ancient browser, so I'll use a modern browser for this. I don't know if it is the same for @FunkyJustin.

Nameless_Contributor said:

......

I forgot to mention it, but filter:images and filter:video can be also be used instead of filter:media. The media filter is basically a combination of the two.

By the way, if you have an example Twitter list, I can start looking into adding autoclick IQDB to it as I mentioned above. However, it'll require a bit more development in order to add this feature, because currently it is setup only for artists, since as you may have noticed in the side menu you have to enable it for every artist you want it to be active on. Doing that basically adds the artist's ID to a list, so I'll have to think of an equivalent way to enable it for a particular list and have each list can be uniquely identified.

Pushed Version 8 which includes:

  • Additions:
    • Side menu can be shown/hidden
      • By clicking the NTISAS header on any tweet
    • Select controls on all image menus
  • Changes:
    • Revamped the tweet menu
      • Now the same for both tweet view and timeline views
      • Download section is now available on timeline views
    • Removed several settings/functions
      • Fade/hide artist highlights
      • Tweet indicators/counters
      • Confirm delete (now always enabled)
      • Autocheck IQDB
      • Merge results (now always enabled)
    • Merge link on image menu is now always shown
    • Viewed highlight shown state saved between page loads
  • Fixes:
    • Accounted for new rating system on Danbooru
    • Added Betabooru to list of subdomains
    • Extraneous images shown for selection
    • Tweets not having the id_str sometimes
    • Detection of tweet cards
    • Dialogue/QTip widths
    • Rendering media link
  • Other:
    • Prototyped several new library functions
    • Used intersection observer to record viewed tweets
    • Fixed several style issues with eslint

Updated

Pushed Version 9 which includes:

  • Additions:
    • Media timeline is now supported
      • media_timeline_enabled - Function tab, user settings.
    • Counting views can be turned on/off
      • When views are enabled, the Count views control is added to the "controls" tab in the side menu.
  • Changes:
    • Removed the API hook
      • Doesn't work on all browsers and userscript managers.
    • Removed displaying retweet IDs
      • Depends on having API data.
    • Removed highlighting tweets
      • This was mainly only available on the media timeline, which no longer supports doing this.
    • Saves non-results on IQDB/Sauce searches
      • Beforehand if there were incorrect results, it would not save this status.
  • Fixes:
    • Post tooltip loading
      • You no longer need to hover over the post link, unhover, then rehover to get the tooltip to properly show up.
    • Multiple videos with download original
      • Video thumbnails are no longer individually shown, though the thumbnail URL is still made a link, so it can be right-click opened in another tab.
  • Other:
    • Removed the XRegExp library

Media timeline

Icons

Uses a mini-icon (lower right) to display Danbooru/Twitter status. The left side is green and shows a number if it has Danbooru posts, and grey with a dot otherwise. The right side shows a number if there is more than one image/video.

A square (upper left) is used to show Tweet views for when this option is enabled. Hovering over this shows the last time viewed, and how many time it has been viewed.

Media menu

Click the mini-icon to bring up the traditional NTISAS menu. It'll also show all available images/videos, which are clickable to either show a larger version of the image, or to play the video.

Tweets are only counted as being viewed on the media timeline when the media menu is accessed.

Network

This option queries the Twitter API, so it may cause the available API usage to run out, causing "HTTP 429 Too Many Requests" errors until the API usage resets.

1