-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReddit on SearXNG Search for mobile.user.js
More file actions
70 lines (36 loc) · 1.43 KB
/
Copy pathReddit on SearXNG Search for mobile.user.js
File metadata and controls
70 lines (36 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// ==UserScript==
// @name Reddit on SearXNG Search
// @namespace https://github.com/Kdroidwin/Reddit-on-SearXNG-Search
// @version 0.1
// @description Add site:reddit.com to SearXNG search queries on button click
// @author Kdroidwim
// @match https://priv.au/*
// @match https://search.inetol.net/*
// @match https://searx.tiekoetter.com/*
// @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);
}
})();