11const DEFAULT_BANG = "d" ;
22
33const bangs = {
4- al : "https://kiwix.tristanhavelick.com/search?content=archlinux_en_all_nopic_2022-05&pattern={{{s}}}" ,
5- cl : "https://denver.craigslist.org/search/?query={{{s}}}" ,
6- d : "https://lite.duckduckgo.com/lite?q={{{s}}}&kl=us-en" ,
7- e : "https://www.ebay.com/sch/i.html?_nkw={{{s}}}&rt=nc&LH_ItemCondition=4" ,
8- jw : "https://www.justwatch.com/us/search?q={{{s}}}" ,
9- k : "https://kiwix.tristanhavelick.com/search?pattern={{{s}}}" ,
10- m : "https://search.marginalia.nu/search?query={{{s}}}" ,
11- py : "https://kiwix.tristanhavelick.com/search?content=python-3.10.2&pattern={{{s}}}" ,
12- sg : "https://app.thestorygraph.com/browse?search_term={{{s}}}" ,
13- ytt : "https://youtranscript.tristanhavelick.com/search?search_term={{{s}}}" ,
14- x : "https://searxng.tristanhavelick.com/search?q={{{s}}}" ,
15- gh : "https://github.com/search?q={{{s}}}" ,
16- ghr : "https://github.com/{{{s}}}" ,
17- wb : "https://web.archive.org/web/{{{s}}}" ,
18- g : "https://www.google.com/search?q={{{s}}}" ,
19- ddg : "https://duckduckgo.com/?q={{{s}}}" ,
20- a : "https://www.amazon.com/s?k={{{s}}}" ,
21- pypi : "https://pypi.org/search/?q={{{s}}}" ,
22- w : "https://en.wikipedia.org/wiki/Special:Search?search={{{s}}}" ,
23- i : "https://duckduckgo.com/?q={{{s}}}&iax=images&ia=images" ,
24- yt : "https://www.youtube.com/results?search_query={{{s}}}" ,
4+ al : {
5+ url : "https://kiwix.tristanhavelick.com/search?content=archlinux_en_all_nopic_2022-05&pattern={{{s}}}" ,
6+ description : "ArchLinux Wiki" ,
7+ } ,
8+ cl : {
9+ url : "https://denver.craigslist.org/search/?query={{{s}}}" ,
10+ description : "Denver Craigslist" ,
11+ } ,
12+ d : {
13+ url : "https://lite.duckduckgo.com/lite?q={{{s}}}&kl=us-en" ,
14+ description : "DuckDuckGo Lite" ,
15+ } ,
16+ e : {
17+ url : "https://www.ebay.com/sch/i.html?_nkw={{{s}}}&rt=nc&LH_ItemCondition=4" ,
18+ description : "eBay (used items)" ,
19+ } ,
20+ jw : {
21+ url : "https://www.justwatch.com/us/search?q={{{s}}}" ,
22+ description : "JustWatch (streaming search)" ,
23+ } ,
24+ k : {
25+ url : "https://kiwix.tristanhavelick.com/search?pattern={{{s}}}" ,
26+ description : "Kiwix Offline Content" ,
27+ } ,
28+ m : {
29+ url : "https://search.marginalia.nu/search?query={{{s}}}" ,
30+ description : "Marginalia Search" ,
31+ } ,
32+ py : {
33+ url : "https://kiwix.tristanhavelick.com/search?content=python-3.10.2&pattern={{{s}}}" ,
34+ description : "Python Documentation" ,
35+ } ,
36+ sg : {
37+ url : "https://app.thestorygraph.com/browse?search_term={{{s}}}" ,
38+ description : "The StoryGraph (books)" ,
39+ } ,
40+ ytt : {
41+ url : "https://youtranscript.tristanhavelick.com/search?search_term={{{s}}}" ,
42+ description : "YouTube Transcript Search" ,
43+ } ,
44+ x : {
45+ url : "https://searxng.tristanhavelick.com/search?q={{{s}}}" ,
46+ description : "SearXNG" ,
47+ } ,
48+ gh : {
49+ url : "https://github.com/search?q={{{s}}}" ,
50+ description : "GitHub Search" ,
51+ } ,
52+ ghr : {
53+ url : "https://github.com/{{{s}}}" ,
54+ description : "GitHub Repository" ,
55+ } ,
56+ wb : {
57+ url : "https://web.archive.org/web/{{{s}}}" ,
58+ description : "Wayback Machine" ,
59+ } ,
60+ g : {
61+ url : "https://www.google.com/search?q={{{s}}}" ,
62+ description : "Google Search" ,
63+ } ,
64+ ddg : {
65+ url : "https://duckduckgo.com/?q={{{s}}}" ,
66+ description : "DuckDuckGo" ,
67+ } ,
68+ a : {
69+ url : "https://www.amazon.com/s?k={{{s}}}" ,
70+ description : "Amazon" ,
71+ } ,
72+ pypi : {
73+ url : "https://pypi.org/search/?q={{{s}}}" ,
74+ description : "Python Package Index" ,
75+ } ,
76+ w : {
77+ url : "https://en.wikipedia.org/wiki/Special:Search?search={{{s}}}" ,
78+ description : "Wikipedia" ,
79+ } ,
80+ i : {
81+ url : "https://duckduckgo.com/?q={{{s}}}&iax=images&ia=images" ,
82+ description : "DuckDuckGo Images" ,
83+ } ,
84+ yt : {
85+ url : "https://www.youtube.com/results?search_query={{{s}}}" ,
86+ description : "YouTube" ,
87+ } ,
2588} ;
2689
2790function buildSearchUrl ( urlTemplate , searchTerm ) {
@@ -39,7 +102,7 @@ function getDefaultBang(windowObj = window) {
39102
40103function buildFallbackUrl ( searchTerm , windowObj = window ) {
41104 const defaultBang = getDefaultBang ( windowObj ) ;
42- const bangUrl = bangs [ defaultBang ] ;
105+ const bangUrl = bangs [ defaultBang ] . url ;
43106 return buildSearchUrl ( bangUrl , searchTerm ) ;
44107}
45108
@@ -59,19 +122,19 @@ function processBang(query, windowObj = window) {
59122 const bangTag = trimmed . substring ( 1 , spaceIndex ) ;
60123 const searchTerm = trimmed . substring ( spaceIndex + 1 ) . trim ( ) ;
61124
62- const bangUrl = bangs [ bangTag ] ;
63- if ( bangUrl ) {
64- return buildSearchUrl ( bangUrl , searchTerm ) ;
125+ const bang = bangs [ bangTag ] ;
126+ if ( bang ) {
127+ return buildSearchUrl ( bang . url , searchTerm ) ;
65128 }
66129 }
67130 const bangMatch = trimmed . match ( / ^ ( .+ ) \s + ( \w + ) ! $ / ) ;
68131 if ( bangMatch ) {
69132 const searchTerm = bangMatch [ 1 ] . trim ( ) ;
70133 const bangTag = bangMatch [ 2 ] ;
71134
72- const bangUrl = bangs [ bangTag ] ;
73- if ( bangUrl ) {
74- return buildSearchUrl ( bangUrl , searchTerm ) ;
135+ const bang = bangs [ bangTag ] ;
136+ if ( bang ) {
137+ return buildSearchUrl ( bang . url , searchTerm ) ;
75138 }
76139 }
77140 return buildFallbackUrl ( trimmed , windowObj ) ;
@@ -300,9 +363,9 @@ class SettingsDialog extends SettingsDialogBase {
300363 <div class="bang-list">
301364 ` ;
302365
303- for ( const [ bangKey , bangUrl ] of sortedBangs ) {
366+ for ( const [ bangKey , bangData ] of sortedBangs ) {
304367 const isSelected = bangKey === currentDefault ;
305- html += `<setting-option bang-key="${ bangKey } " bang-url="${ bangUrl } "${ isSelected ? " selected" : "" } ></setting-option>` ;
368+ html += `<setting-option bang-key="${ bangKey } " bang-url="${ bangData . url } " bang-description=" ${ bangData . description } "${ isSelected ? " selected" : "" } ></setting-option>` ;
306369 }
307370
308371 html += `
@@ -358,12 +421,15 @@ class SettingOption extends SettingOptionBase {
358421 render ( ) {
359422 const bangKey = this . getAttribute ( "bang-key" ) ;
360423 const bangUrl = this . getAttribute ( "bang-url" ) ;
424+ const bangDescription = this . getAttribute ( "bang-description" ) ;
361425 const isSelected = this . hasAttribute ( "selected" ) ;
362426
363427 this . innerHTML = `
364- <div class="bang-trigger">${ bangKey } !</div>
365- <div class="bang-url">${ bangUrl } </div>
366- <input type="radio" name="default-bang" value="${ bangKey } " class="bang-radio"${ isSelected ? " checked" : "" } >
428+ <div class="setting-row">
429+ <div class="bang-trigger">${ bangKey } !</div>
430+ <div class="bang-description" title="${ bangUrl } ">${ bangDescription } </div>
431+ <input type="radio" name="default-bang" value="${ bangKey } " class="bang-radio"${ isSelected ? " checked" : "" } >
432+ </div>
367433 ` ;
368434 }
369435
0 commit comments