Google Search - Quick Sites

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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

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