[Userscript] Booru Switcher

Marker

One Man Illuminati
Booru Switcher

Let's you quickly switch between Philomena-based boorus. Primarily intended for quickly comparing tags and searches across sites.

Requires Violentmonkey or compatible userscript manager.
Click here to install from Github

Screenshot


Known issue
There's a bug where the file hash returned by the site's API doesn't match the actual file.

If such an image was downloaded from Site A then uploaded to Site B. Trying to search for the image from Site A would find no result. As a workaround, you can ctrl + click the link again to force the script to download the full image and compute the hash client side.

This let you search on Site A for images that had been uploaded to Site B. However, it won't work for the inverse, i.e. find the source image on Site A from Site B. So, when client-side hashing fails to yield result, the script uses Philomena's reverse image search function as the final fallback.
Marker

One Man Illuminati
Changelog for version 1.1.0:
- Enabled on image pages: Added the ability to search for an image by its file hash, and redirects to it if found.
Background Pony #71A7
I think the screenshot is a broken image link.

Thanks for making the tool, by the way.
Background Pony #71A7
@Marker
So it does.

What's the deal with "Trixiebooru"? It seems to be a url that's just aliased to Derpibooru. I even checked out the forums, and the forums had all the same stuff in them. That means that Derpibooru is two of the four boorus linked to in this script, if I'm understanding things right.
Marker

One Man Illuminati
Changelog for version 1.1.4:
- Image search: updated to address a known bug that would erroneously mark an image as not found, see OP for details.

Edit: added reverse image search as a final fallback.
Edit2: fixed the script not working for Ponerpics.

@Background Pony #F6C0
Indeed. Trixiebooru is an alternate domain for Derpibooru.
There are valid reasons why some users might want to switch between the two, so I included the two domains to accommodate them.
Marker

One Man Illuminati
@ToastedTruffles
Ah, I didn't know about the ponerpics.com domain. This one is slightly more problematic because now I have to display the tld in order to distinguish between the two.

Hmm. On one hand, I don't want to force users to use one version of a site's domain over the other. On the other hand, I fear simply adding them all to the list will eventually lead it to becoming too cluttered. Adding a second level of menu for each site could work but 1) It slows down navigation for all users, 2) Unnecessary for sites with only a single domain and that kinda bugs me, and 3) Requires rewriting existing code which I'm too lazy to do right now.
Or maybe have a setting for users to indicate their prefered domain…?

Is this an important issue to you? I would prefer to shelve this for now to focus on other things, and come back to it later or if there's a demand for it.
ToastedTruffles

Early Adopter
It's not that important. I'm just a bit curious that DB literally makes up most of the list with it's two domains. If multiple competing boorus becomes a trend with the upcoming Twibooru, and whether Rainbooru will eventually be added to this script's compatibility, then the best decision for site visibility will be to have a bunch of domains so that they get to be the most entries on the dropdown menu.

What are the reasons someone might prefer to go to Trixiebooru instead of Derpibooru, by the way? Does the site offer special functionality, or is it just a different default website theme?
Marker

One Man Illuminati
@ToastedTruffles
The way I heard it is that some people may keep different accounts (For different filters, or for RP purposes). And it's easier for them to simply stay logged in on one account in one domain and a different account on the other, rather than signing out then signing in again on the same domain. I also included Trixiebooru for the few weirdos out there that uses it as the primary domain. When I first wrote the script I made the wrong assumption that having alternate domains is the exception rather than the norm.
Marker

One Man Illuminati
Changelog for 1.1.6:
- Improved accuracy of image redirect when reverse image search is used. [commit]
- Workaround for a bug affects Violentmonkey on Firefox that breaks image search [commit]
Marker

One Man Illuminati
Changelog for 1.2.0:
- Added partial compatibility for Twibooru: Hash via API and client-side hashing works. No support for reverse image search.
ToastedTruffles

Early Adopter
Thanks for the continued updates.

Unfortunately, I have a problem to report: When I'm on PonerPics looking at an image, say 2168912, and I try to open the drop down menu to swap to look at the image on other sites, the entry for the site I try to switch to in the drop down menu changes from saying "Search on [Other Site]" to "Something went wrong".

As far as one or two quick tests I did just now goes, swapping from the search results page on PonerPics to the search results page of the same search on one of the other sites seems to work just fine.
ToastedTruffles

Early Adopter
I'm using Dissenter. It's based on Brave, which is based on Chrome.

The error message that popped up says the following:

TypeError: Cannot read property 'image' of undefined
at eval (userscript.html?name=Booru%20Switcher.user.js&id=adc1003d-5e1e-4e1c-aa07-e5a544314308:218)
at async HTMLElement.eval (userscript.html?name=Booru%20Switcher.user.js&id=adc1003d-5e1e-4e1c-aa07-e5a544314308:107)
eval @ userscript.html?name=Booru%20Switcher.user.js&id=adc1003d-5e1e-4e1c-aa07-e5a544314308:123
async function (async)
eval @ userscript.html?name=Booru%20Switcher.user.js&id=adc1003d-5e1e-4e1c-aa07-e5a544314308:107

The userscript is names as follows:
userscript.html?name=Booru%20Switcher.user.js&id=adc1003d-5e1e-4e1c-aa07-e5a544314308:123 TypeError: Cannot read property 'image' of undefined

Here's a screencap of the relevant error:

Link to image page since the "insert image" with direct linking doesn't seem to want to show in this post.
Marker

One Man Illuminati
@ToastedTruffles
Ah, I neglected to ask which userscript manager you're using.
Also, clicking on the links in the error message should take you to the corresponding line in the code. Could you click on each of them and tell me what they are?
Syntax quick reference: *bold* _italic_ [spoiler]hide text[/spoiler] @code@ +underline+ -strike- ^sup^ ~sub~