@@ -10,6 +10,7 @@ import { metadata } from "../../services/metadata.js";
1010import { performSearchPage } from "../search/search.js" ;
1111const QUERY_DATABASE_EXPIRATION = 1000 * 60 * 60 * 24 * 30 ; // 30 days
1212const queryDatabase = new Map ( ) ;
13+
1314function saveTabQueryToDatabase ( query , tab , url ) {
1415 queryDatabase . set ( query . toLowerCase ( ) , {
1516 url,
@@ -28,6 +29,7 @@ function saveTabQueryToDatabase(query, tab, url) {
2829 } , 1000 ) ;
2930 saveQueryDatabase ( ) ;
3031}
32+
3133intentRunner . registerIntent ( {
3234 name : "navigation.navigate" ,
3335 async run ( context ) {
@@ -61,6 +63,7 @@ intentRunner.registerIntent({
6163 context . done ( ) ;
6264 } ,
6365} ) ;
66+
6467intentRunner . registerIntent ( {
6568 name : "navigation.clearQueryDatabase" ,
6669 async run ( context ) {
@@ -69,6 +72,7 @@ intentRunner.registerIntent({
6972 context . presentMessage ( '"Open" database/cache cleared' ) ;
7073 } ,
7174} ) ;
75+
7276intentRunner . registerIntent ( {
7377 name : "navigation.bangSearch" ,
7478 async run ( context ) {
@@ -101,6 +105,7 @@ intentRunner.registerIntent({
101105 }
102106 } ,
103107} ) ;
108+
104109intentRunner . registerIntent ( {
105110 name : "navigation.translate" ,
106111 async run ( context ) {
@@ -112,6 +117,7 @@ intentRunner.registerIntent({
112117 browser . tabs . update ( tab . id , { url : translation } ) ;
113118 } ,
114119} ) ;
120+
115121intentRunner . registerIntent ( {
116122 name : "navigation.translateSelection" ,
117123 async run ( context ) {
@@ -129,6 +135,7 @@ intentRunner.registerIntent({
129135 await browser . tabs . create ( { url } ) ;
130136 } ,
131137} ) ;
138+
132139async function saveQueryDatabase ( ) {
133140 const expireTime = Date . now ( ) - QUERY_DATABASE_EXPIRATION ;
134141 const entries = [ ] ;
@@ -139,6 +146,7 @@ async function saveQueryDatabase() {
139146 }
140147 await browser . storage . local . set ( { queryDatabase : entries } ) ;
141148}
149+
142150intentRunner . registerIntent ( {
143151 name : "navigation.goBack" ,
144152 async run ( context ) {
@@ -148,6 +156,7 @@ intentRunner.registerIntent({
148156 } ) ;
149157 } ,
150158} ) ;
159+
151160intentRunner . registerIntent ( {
152161 name : "navigation.goForward" ,
153162 async run ( context ) {
@@ -157,6 +166,7 @@ intentRunner.registerIntent({
157166 } ) ;
158167 } ,
159168} ) ;
169+
160170intentRunner . registerIntent ( {
161171 name : "navigation.followLink" ,
162172 async run ( context ) {
@@ -176,6 +186,7 @@ intentRunner.registerIntent({
176186 }
177187 } ,
178188} ) ;
189+
179190intentRunner . registerIntent ( {
180191 name : "navigation.signInAndOut" ,
181192 async run ( context ) {
@@ -193,6 +204,7 @@ intentRunner.registerIntent({
193204 }
194205 } ,
195206} ) ;
207+
196208intentRunner . registerIntent ( {
197209 name : "navigation.closeDialog" ,
198210 async run ( context ) {
@@ -210,6 +222,7 @@ intentRunner.registerIntent({
210222 }
211223 } ,
212224} ) ;
225+
213226intentRunner . registerIntent ( {
214227 name : "navigation.internetArchive" ,
215228 async run ( context ) {
@@ -219,6 +232,7 @@ intentRunner.registerIntent({
219232 } ) ;
220233 } ,
221234} ) ;
235+
222236async function loadQueryDatabase ( ) {
223237 const result = await browser . storage . local . get ( [ "queryDatabase" ] ) ;
224238 if ( result && result . queryDatabase ) {
@@ -227,4 +241,5 @@ async function loadQueryDatabase() {
227241 }
228242 }
229243}
244+
230245loadQueryDatabase ( ) ;
0 commit comments