Google Search - Quick Sites

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

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