Find this image on SauceNAO

tries to find currently opened image on SauceNAO

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==UserScript==
// @name         Find this image on SauceNAO
// @namespace    http://t.me/therealkww/
// @version      2024-01-21
// @description  tries to find currently opened image on SauceNAO
// @author       kww
// @license      WTFPL
// @match        *://chan.sankakucomplex.com/*posts/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=sankakucomplex.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    let stats = document.getElementById('stats');
    let h5Header = stats.nextElementSibling.firstChild.nextElementSibling; // works on my machine

    // Check if the h5 header exists
    if (h5Header) {
        // Get the next sibling element of the h5 header
        const nextElement = h5Header.nextElementSibling;

        // Check if the next sibling is a list (ul)
        if (nextElement.tagName.toLowerCase() === 'ul') {
            // Create a new list item and link
            let listItem = document.createElement('li');
            let linkTag = document.createElement('a');

            // Retrieve href attribute from <a> tag with id "lowres"
            let link = document.getElementById('lowres');
            let href;
            if (link) {
                href = link.getAttribute('href')
                linkTag.textContent = 'Find sauce by thumbnail';
                linkTag.setAttribute('href', `https://saucenao.com/search.php?db=999&dbmaski=32768&url=${encodeURIComponent(href)}`);
                linkTag.setAttribute('target', '_blank'); // open in new tab
                listItem.appendChild(linkTag);
                nextElement.appendChild(listItem);
            }

            // Create a new list item and link
            listItem = document.createElement('li');
            linkTag = document.createElement('a');

            // Retrieve href attribute from <a> tag with id "highres"
            link = document.getElementById('highres');
            if (link) {
                href = link.getAttribute('href')
                linkTag.textContent = 'Find sauce by source';
                linkTag.setAttribute('href', `https://saucenao.com/search.php?db=999&dbmaski=32768&url=${encodeURIComponent(href)}`);
                linkTag.setAttribute('target', '_blank'); // open in new tab
                listItem.appendChild(linkTag);
                nextElement.appendChild(listItem);
            }

            //else abort
        }
    }
})();