Find this image on SauceNAO

try to find this image on SauceNAO!

Verzia zo dňa 21.01.2024. Pozri najnovšiu verziu.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

// ==UserScript==
// @name         Find this image on SauceNAO
// @namespace    http://t.me/therealkww/
// @version      2024-01-21
// @description  try to find this image on SauceNAO!
// @author       kww
// @license MIT
// @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 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 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
        }
    }
})();