Greasy Fork is available in English.

Google Search - Quick Sites

Adds Filmweb, Letterboxd, MyAnimeList, Backloggd, and Reddit buttons to Google Search tools to quickly append them to your query.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Google Search - Quick Sites
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Adds Filmweb, Letterboxd, MyAnimeList, Backloggd, and Reddit buttons to Google Search tools to quickly append them to your query.
// @author       qualia
// @match        https://www.google.com/search*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=google.com
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // The sites and the text we want to append
    const sites = [
        { name: 'filmweb', domain: 'filmweb.pl' },
        { name: 'letterboxd', domain: 'letterboxd.com' },
        { name: 'myanimelist', domain: 'myanimelist.net' },
        { name: 'backloggd', domain: 'backloggd.com' },
        { name: 'reddit', domain: 'reddit.com' }
    ];

    function appendTermAndSearch(term) {
        const urlParams = new URLSearchParams(window.location.search);
        let query = urlParams.get('q') || '';

        if (!query.toLowerCase().includes(term.toLowerCase())) {
            query += ` ${term}`;
            urlParams.set('q', query);
            urlParams.delete('start');
            window.location.href = `/search?${urlParams.toString()}`;
        }
    }

    function createIcons() {
        if (document.getElementById('custom-site-appender-icons')) return;

        const targetContainer = document.querySelector('.rQTE8b');
        if (!targetContainer) return;

        const iconWrapper = document.createElement('div');
        iconWrapper.id = 'custom-site-appender-icons';
        iconWrapper.style.display = 'flex';
        iconWrapper.style.alignItems = 'center';
        iconWrapper.style.marginLeft = '8px';
        iconWrapper.style.gap = '4px';

        sites.forEach(site => {
            const btn = document.createElement('div');
            btn.title = `Append "${site.name}" and search`;
            btn.style.cursor = 'pointer';
            btn.style.display = 'flex';
            btn.style.alignItems = 'center';
            btn.style.justifyContent = 'center';
            btn.style.width = '32px';
            btn.style.height = '32px';
            btn.style.borderRadius = '50%';
            btn.style.transition = 'background-color 0.2s';

            btn.onmouseover = () => { btn.style.backgroundColor = 'rgba(128, 128, 128, 0.2)'; };
            btn.onmouseout = () => { btn.style.backgroundColor = 'transparent'; };

            const img = document.createElement('img');
            img.src = `https://www.google.com/s2/favicons?sz=32&domain=${site.domain}`;
            img.style.width = '16px';
            img.style.height = '16px';
            img.style.borderRadius = '2px';

            btn.appendChild(img);

            btn.addEventListener('click', (e) => {
                e.preventDefault();
                appendTermAndSearch(site.name);
            });

            iconWrapper.appendChild(btn);
        });

        targetContainer.appendChild(iconWrapper);
    }

    const observer = new MutationObserver(() => {
        if (document.querySelector('.rQTE8b') && !document.getElementById('custom-site-appender-icons')) {
            createIcons();
        }
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

    createIcons();
})();