about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-09-30 22:08:43 +0200
committerbptato <nincsnevem662@gmail.com>2024-09-30 22:27:40 +0200
commit7277dd7c357cfa10838b1e694aaf32128082d088 (patch)
treedd62ac89a9f0c6e30385b5cbeed8611bf859ff7c
parent9eb459ad095aa3fb30d967359e0bc6846262f6ea (diff)
downloadchawan-7277dd7c357cfa10838b1e694aaf32128082d088.tar.gz
config.toml: switch to Google search
I'm not happy about this, but the alternatives are worse.

* DDG has degraded a lot lately:
	- (I think?) it appends my location to the Bing queries, which
	  might be useful for searching restaurants, but only increases
	  noise when looking for something technical.
	- Lately it also shoves LLM-generated summaries of websites in
	  my face - which I wouldn't even mind if the "summaries"
	  weren't in the typical overly verbose LLM style...
  Also, not a degradation per se, but DDG can't load images without JS
  (neither lite nor html), while Google can. Only relevant now that we
  have images.
* Other large search providers either don't load without JS, or give
  us a layout that we can't render.
* Smaller search providers (Mojeek, Marginalia) sadly don't have CJK
  support. (DDG performs quite poorly here, too.)
* Metasearch engines (Searx, etc.) require self-hosting to work
  consistently, which I lack resources for.

I'm sending ucbcb=1 and gbv=1, both of which are appended by Google
and apparently stand for "no cookies" and "no JS", respectively.
Also, I have added a siteconf entry to strip the click tracking.

The default ddg: omni-rule remains, so users who wish to switch back can
set in config.toml:

[page]
C-k = '() => pager.load("ddg:")'
-rw-r--r--doc/config.md13
-rw-r--r--res/config.toml18
2 files changed, 28 insertions, 3 deletions
diff --git a/doc/config.md b/doc/config.md
index a69e16f5..d32166b7 100644
--- a/doc/config.md
+++ b/doc/config.md
@@ -612,7 +612,9 @@ omni-rules. These are to be placed in the table array `[[omnirule]]`.
 
 Examples:
 ```
-# Search using DuckDuckGo Lite. (Bound to C-k by default.)
+# Search using DuckDuckGo Lite.
+# (This rule is included in the default config, although C-k now invokes
+# Google search.)
 [[omnirule]]
 match = '^ddg:'
 substitute-url = '(x) => "https://lite.duckduckgo.com/lite/?kp=-1&kd=-1&q=" + encodeURIComponent(x.split(":").slice(1).join(":"))'
@@ -879,9 +881,16 @@ Examples:
 ```toml
 # show change URL when Control, Escape and j are pressed
 'C-M-j' = 'cmd.pager.load'
+
 # go to the first line of the page when g is pressed twice without a preceding
 # number, or to the line when a preceding number is given.
 'gg' = 'cmd.buffer.gotoLineOrStart'
+
+# JS functions and expressions are accepted too. Following replaces the
+# default search engine with DuckDuckGo Lite.
+# (See api.md for a list of available functions, and a discussion on how
+# to add your own "namespaced" commands like above.)
+'C-k' = '() => pager.load("ddg:")'
 ```
 
 ### Pager actions
@@ -918,7 +927,7 @@ downloading something, that will be delayed until you restart the process.</td>
 <td><kbd>C-k</kbd></td>
 <td>`cmd.pager.webSearch`</td>
 <td>Open the URL bar with an arbitrary search engine. At the moment, this is
-DuckDuckGo Lite, but this may change in the future.</td>
+Google Search, but this may change in the future.</td>
 </tr>
 
 <tr>
diff --git a/res/config.toml b/res/config.toml
index 13210838..43a61072 100644
--- a/res/config.toml
+++ b/res/config.toml
@@ -56,7 +56,7 @@ toggleWrap = '''
 '''
 dupeBuffer = '() => pager.dupeBuffer()'
 load = '() => pager.load()'
-webSearch = '() => pager.load("ddg:")'
+webSearch = '() => pager.load("go:")'
 openBookmarks = '() => pager.loadSubmit("~/.w3m/bookmark.html")'
 reloadBuffer = '() => pager.reload()'
 lineInfo = '() => pager.lineInfo()'
@@ -319,6 +319,22 @@ force-pixels-per-line = false
 match = '^ddg:'
 substitute-url = 'x => "https://lite.duckduckgo.com/lite/?kp=-1&kd=-1&q=" + encodeURIComponent(x.split(":").slice(1).join(":"))'
 
+[[omnirule]]
+match = '^go:'
+substitute-url = 'x => `https://www.google.com/search?gbv=1&ucbcb=1&q=${x.split(":").slice(1).join(":")}`'
+
+# strip tracking
+[[siteconf]]
+url = '^https?://(www\.)?google\.com'
+rewrite-url = '''
+x => {
+	if (x.pathname == "/url")
+		return new URL(x.searchParams.get("q"));
+	for (const name of ["sca_esv", "sca_upv", "oq", "aqs", "ved", "sa", "source", "ei"])
+		x.searchParams.delete(name);
+}
+'''
+
 [page]
 # buffer commands
 h = 'cmd.buffer.cursorLeft'