Find this image on SauceNAO

tries to find currently opened image on SauceNAO

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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
        }
    }
})();