Greasy Fork

Greasy Fork is available in English.

Reddit on SearXNG Search for mobile

Add site:reddit.com to SearXNG search queries on button click

当前为 2025-04-16 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==

// @name         Reddit on SearXNG Search for mobile

// @namespace    https://github.com/Kdroidwin/Reddit-on-SearXNG-Search

// @version      0.31

// @description  Add site:reddit.com to SearXNG search queries on button click

// @author       Kdroidwim
// @license GPL-3.0 license

// @match        https://priv.au/*
// @match        https://search.inetol.net/*
// @match        https://searx.tiekoetter.com/*
// @match        https://searx.be/search*
// @match        https://opnxng.com/search*
// @match        https://searxng.hweeren.com/search*

// @grant        none

// ==/UserScript==

(function() {

    'use strict';

    // SearXNG の検索フォームと検索入力フィールドのセレクタを取得

    const searchForm = document.querySelector('form[action="/search"]');

    const searchInput = document.querySelector('input[name="q"]');

    // Reddit 検索用のボタンを作成

    const redditButton = document.createElement('button');

    redditButton.textContent = 'Search Reddit';

    redditButton.type = 'button';

    redditButton.style.marginLeft = '10px';

    // ボタンのクリックイベントを追加

    redditButton.addEventListener('click', function() {

        let query = searchInput.value;

        // クエリに site:reddit.com を追加

        if (!query.includes('site:reddit.com')) {

            searchInput.value = query + ' site:reddit.com';

        }

        // フォームを送信

        searchForm.submit();

    });

    // 検索フォームにボタンを追加

    if (searchForm) {

        searchForm.appendChild(redditButton);

    }

})();