Google Search - Quick Sites

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

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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();
})();