Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> [Script] gallery hash compare

 
post Mar 7 2022, 14:49
Post #1
atasitian



Casual Poster
****
Group: Members
Posts: 422
Joined: 18-July 10
Level 322 (Godslayer)


This is conceptually very similar to Dnkz's script, but with a few differences (e.g. no external dependencies like jquery.com).

This userscript compares the image hashes of two galleries, which can be helpful when deciding if and which gallery to expunge.

Usage:
  1. make sure you're browsing image galleries in "large thumbnail" mode, otherwise the script won't work at all
  2. visit the first gallery
  3. click on the new "Compare Hashes" button that is haphazardly placed in the top right corner of the page
  4. an inline popup opens, showing the current URL in the "This gallery" field (top left)
  5. paste the URL of the second gallery in the field labeled "Other gallery" (top right)
  6. click on the "Collect hashes (A)" button (bottom left) and (if the gallery is large) wait for it to finish
  7. click on the "Collect hashes (B​)" button (bottom right) and (if the gallery is large) wait for it to finish
  8. click on the "Compare" button (bottom middle)
  9. read off results
It looks like this: Attached Image

The two lists of gallery contents are highlighted to visualize the results. Images that appear in both galleries are marked green. Images that appear multiple times within the same gallery get a yellow "dupe" marker.

A short summary appears under the "Compare" button. It will tell you if the galleries contain the same images (and if so, whether they are in the same order, or otherwise the first out-of-order page), or if one gallery is a subset of the other, or otherwise how many images the galleries have in common.

Caveats:
  • The script only looks at the hashes of raw image files, so even visually identical images will be treated as different if they are not the exact same file. (Any other changes--different image format, size, resolution, etc.--will also lead to a different hash, of course.) This limits the usefulness of the script somewhat, but it is still nice for recognizing exact copies.
  • Collecting image hashes involves visiting all thumbnail pages of a gallery in the background. The script has no built-in rate limit, but it works sequentially (i.e. it will completely process one thumbnail page before fetching the next), so it won't send a hundred HTTP requests in parallel. For large galleries (with hundreds or thousands of pages) this can take a few seconds. If you have the option to show more thumbnails per page (Hath perk "more thumbs"), that would make the script more efficient.

Latest version:
2022-10-18 Attached File  gallery_hash_compare_e_hentai.org.1.2.0.user.js.txt ( 17.24k ) Number of downloads: 1952

Changes:
  • Fix: The "Compare Hashes" button is now placed on top of other page elements, so it will be visible even when it overlaps other elements.
  • The "Other gallery" input field is now automatically focused when the popup opens.
  • The script can now be activated automatically from links. If the opened URL ends with a page anchor (hash) of the form "#:hashcmp:/g/GALLERYID/GALLERYTOKEN/" (where GALLERYID is the numeric ID of the other gallery and GALLERYTOKEN is the alphanumeric gallery token), for example https://e-hentai.org/g/2155332/aaae7b098a/#...459/f267c91b21/, then the current gallery is automatically compared to the other gallery specified in the hash parameter. This doesn't really do anything by itself, but it can be used by other scripts to create auto-compare links.


Previous versions:
2022-06-13 Attached File  gallery_hash_compare_e_hentai.org.1.1.3.user.js.txt ( 21.6k ) Number of downloads: 33

Changes:
  • comparison results are described slightly differently (e.g. instead of "B is a subset of A" it now says "A is a superset of B", always listing the left gallery first)
  • the script will always tell you whether common images have the same relative order in both galleries (previously it would only do so if the galleries were permutations of each other)
  • images marked as duplicate now also link back to the original
  • the pop-up can be closed with the Esc key
2022-03-07 Attached File  gallery_hash_compare_e_hentai.org.user.js.txt ( 17.36k ) Number of downloads: 41


This post has been edited by atasitian: Oct 18 2022, 12:48
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Mar 11 2022, 00:38
Post #2
Mayriad



SUPER ★ BUSY ★ TIME
*******
Group: Global Mods
Posts: 2,061
Joined: 18-December 10
Level 135 (Lord)


I am a bit too busy to have a better look, but I have added it to the userscript index now. Thanks for this new script.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Oct 18 2022, 12:51
Post #3
atasitian



Casual Poster
****
Group: Members
Posts: 422
Joined: 18-July 10
Level 322 (Godslayer)


Script updated to version 1.2.0.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Oct 30 2024, 21:15
Post #4
Waitugreat



Irregular Poster
*******
Group: Gold Star Club
Posts: 1,309
Joined: 15-June 16
Level 456 (Dovahkiin)


This script doesn't seem to work anymore since some days.

Firefox 132.0 (64-Bit)
Tampermonkey v5.3.1

Does anyone else use Tampermonkey and can confirm it? Does it work with another browser or extension?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Oct 30 2024, 23:55
Post #5
Lady_Slayer



Member of the Bal'masqué
*********
Group: Catgirl Camarilla
Posts: 5,357
Joined: 20-December 16
Level 500 (Ponyslayer)


QUOTE(Waitugreat @ Oct 31 2024, 03:15) *

This script doesn't seem to work anymore since some days.

Firefox 132.0 (64-Bit)
Tampermonkey v5.3.1

Does anyone else use Tampermonkey and can confirm it? Does it work with another browser or extension?


yes, that's true. I remember that tempermonkey's most up-to-date version screws something up so that some javascripts won't work as intent. I haven't try it on other monkeys yet, maybe it would back to work on other script addons.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Oct 31 2024, 00:33
Post #6
Waitugreat



Irregular Poster
*******
Group: Gold Star Club
Posts: 1,309
Joined: 15-June 16
Level 456 (Dovahkiin)


Mh. I tried an older version of Tampermonkey but the script still doesn't work. Violentmonkey (on FF) doesn't work either.

Edit: Just downloaded Chrome and Tampermonkey. Doesn't work.

I suspect it has something to do with the recent DOM changes on e-hentai, whatever this means. https://e-hentai.org/news.php
Or maybe there was another change with the website.

This post has been edited by Waitugreat: Oct 31 2024, 00:44
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Oct 31 2024, 12:01
Post #7
aklfhl



Casual Poster
***
Group: Members
Posts: 191
Joined: 8-February 14
Level 332 (Godslayer)


QUOTE(Waitugreat @ Oct 31 2024, 06:33) *

I suspect it has something to do with the recent DOM changes on e-hentai, whatever this means. https://e-hentai.org/news.php
Or maybe there was another change with the website.

Yeah, it's due to that.
You can fix it by replacing
CODE

!document.querySelector('#gdt .gdtl a[href] img[src]')

in line 25 with
CODE

!document.querySelector('#gdt a[href] div[title]')

and
CODE

for (const img of root.querySelectorAll('.gdtl a[href*="/s/"] > img[src]')) {
    const m = /^[^#?]*?\/([\da-f]{40})-/.exec(img.src);
    if (!m) {
        continue;
    }
    const a = img.parentElement;
    hashes.push({
        hash: m[1],
        url: a.href,
        title: img.title || a.href,
    });
}

in line 169-180 with
CODE

for (const a of root.querySelectorAll('#gdt a[href*="/s/"]')) {
     const div = a.querySelector('div[title]');
     if (!div) {
         continue;
     }
     hashes.push({
         hash: div.dataset.orghash,
         url: a.href,
         title: div.title || a.href,
     });
}


Note you also need to add the datatags cookie for it to work.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Oct 31 2024, 13:59
Post #8
Waitugreat



Irregular Poster
*******
Group: Gold Star Club
Posts: 1,309
Joined: 15-June 16
Level 456 (Dovahkiin)


I see. Thanks for your answer!
Since Lain is not my savior and I never worked with such scripts, I don't know what I'm doing (or more what the scripts are doing), so I better just wait until the script gets updated or another one appears. lol

And I just realized that such scripts are a bit more complex than I thought.

Anyway, thank you for your code examples!

(but hey, at least I have a good excuse now to stay away from vigilante stuff)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Oct 31 2024, 15:44
Post #9
aklfhl



Casual Poster
***
Group: Members
Posts: 191
Joined: 8-February 14
Level 332 (Godslayer)


You can try this:
Attached File  gallery_hash_compare_e_hentai.org.1.2.0_20241031fix.user.js.txt ( 17.2k ) Number of downloads: 162

You may need to refresh 1-2 times after installation for it to work.

This post has been edited by aklfhl: Oct 31 2024, 15:49
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

 
post Nov 4 2024, 17:11
Post #10
Guardian of Loli



Active Poster
*******
Group: Gold Star Club
Posts: 1,255
Joined: 26-April 17
Level 386 (Dovahkiin)


QUOTE(aklfhl @ Oct 31 2024, 21:44) *

You can try this:
Attached File  gallery_hash_compare_e_hentai.org.1.2.0_20241031fix.user.js.txt ( 17.2k ) Number of downloads: 162

You may need to refresh 1-2 times after installation for it to work.


It works.
Thank you so much.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 


Lo-Fi Version Time is now: 2nd April 2025 - 08:11