11// ==UserScript==
22// @name Force SearXNG Parameters
33// @icon https://external-content.duckduckgo.com/ip3/searx.space.ico
4- // @version 0.16
4+ // @version 0.17
55// @downloadURL https://userscripts.codonaft.com/force-searxng-parameters.user.js
66// ==/UserScript==
77
@@ -54,7 +54,7 @@ const params = {
5454 'enabled_plugins' : ENABLED_PLUGINS . join ( ',' ) ,
5555 'image_proxy' : 'True' ,
5656 'safesearch' : 0 ,
57- ...Object . fromEntries ( hashParams . entries ( ) ) ,
57+ ...Object . fromEntries ( Array . from ( hashParams . entries ( ) ) ) , // NOTE: fails on Firefox without Array.from
5858} ;
5959
6060const random = ( min , max ) => Math . floor ( Math . random ( ) * ( max - min + 1 ) + min ) ;
@@ -87,13 +87,26 @@ const form = b.querySelector('form#search');
8787const queryInput = b . querySelector ( 'input#q[type="text"]' ) ;
8888if ( form && queryInput ) {
8989 try {
90+ form . method = METHOD ;
91+
9092 const action = form . action . split ( '#' ) [ 0 ] ;
9193 queryInput . addEventListener ( 'input' , _ => {
9294 console . log ( 'query' , queryInput . value ) ;
9395 const newParams = new URLSearchParams ( { ...params , q : queryInput . value } ) ;
9496 form . action = `${ action } #${ newParams } ` ;
97+ if ( ! params . autocomplete ) {
98+ event . preventDefault ( ) ;
99+ event . stopImmediatePropagation ( ) ;
100+ }
95101 } , true ) ;
96- form . method = METHOD ;
102+
103+ if ( ! params . autocomplete ) {
104+ [ 'click' , 'mousedown' , 'keyup' , 'Tab' , 'Enter' ] . forEach ( i => queryInput . addEventListener ( i , event => {
105+ event . preventDefault ( ) ;
106+ event . stopImmediatePropagation ( ) ;
107+ } ) ) ;
108+ }
109+
97110 Object . entries ( params ) . forEach ( ( [ k , v ] ) => {
98111 if ( k === 'q' ) return ;
99112 const input = document . createElement ( 'input' ) ;
@@ -109,13 +122,6 @@ if (form && queryInput) {
109122
110123Object . entries ( cookies ) . forEach ( ( [ k , v ] ) => document . cookie = `${ k } =${ v } ` ) ;
111124
112- if ( ! params . autocomplete ) {
113- const autocomplete = b . querySelector ( 'div.autocomplete' ) ;
114- if ( autocomplete ) {
115- autocomplete . style . display = 'none !important' ;
116- }
117- }
118-
119125/*const subscribeOnChanges = (node, selector, f) => {
120126 const apply = (node, observer) => {
121127 if (node?.nodeType !== 1) return;
0 commit comments