✨ Add Firefox search engine support #46
4 changed files with 54 additions and 13 deletions
|
|
@ -19,12 +19,18 @@
|
|||
AppMain,
|
||||
AppFooter
|
||||
},
|
||||
'data': () => ({
|
||||
isLoading: false,
|
||||
items: [],
|
||||
filterData: undefined,
|
||||
filters: undefined
|
||||
}),
|
||||
data(){
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const initialQuery = (urlParams.get('q') || urlParams.get('query') || '').trim();
|
||||
|
||||
return {
|
||||
initialQuery,
|
||||
isLoading: false,
|
||||
items: [],
|
||||
filterData: undefined,
|
||||
filters: undefined
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
apiUrl: () => apiUrl,
|
||||
filteredItems: function(){
|
||||
|
|
@ -67,8 +73,19 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
updateSearchUrl: function(query){
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.delete('query');
|
||||
if(query)
|
||||
url.searchParams.set('q', query);
|
||||
else
|
||||
url.searchParams.delete('q');
|
||||
window.history.replaceState(window.history.state, '', url);
|
||||
},
|
||||
search: async function(query){
|
||||
query = (query || '').trim();
|
||||
this.isLoading = true;
|
||||
this.updateSearchUrl(query);
|
||||
this.filterData = undefined;
|
||||
this.items.splice(0, this.items.length);
|
||||
try {
|
||||
|
|
@ -133,12 +150,16 @@
|
|||
}
|
||||
);
|
||||
window._sentry = Sentry;
|
||||
|
||||
if(this.initialQuery)
|
||||
this.search(this.initialQuery);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template class="App">
|
||||
<AppHeader
|
||||
:initial-query="initialQuery"
|
||||
:api-url="apiUrl"
|
||||
:is-loading="isLoading"
|
||||
@submit-search="search"
|
||||
|
|
@ -166,4 +187,4 @@
|
|||
flex-direction: column;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -2,11 +2,14 @@
|
|||
export default {
|
||||
props: {
|
||||
apiUrl: undefined,
|
||||
isLoading: undefined
|
||||
isLoading: undefined,
|
||||
initialQuery: undefined
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
query: this.initialQuery
|
||||
};
|
||||
},
|
||||
'data': () => ({
|
||||
query: ''
|
||||
}),
|
||||
methods: {
|
||||
submit: function(event){
|
||||
if(this.query && !this.isLoading){
|
||||
|
|
@ -94,4 +97,4 @@
|
|||
content: '|';
|
||||
padding: 0 0.5rem;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
</style>
|
||||
<link rel="manifest" href="data:application/manifest+json,%7B%22name%22%3A%22Advanced%20Google%20Play%20Search%22%2C%22shortName%22%3A%22playsearch.kaki87.net%22%7D">
|
||||
<link rel="icon" href="./assets/favicon.png">
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="Advanced Google Play Search" href="/opensearch.xml">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Glagan/SimpleNotification@v1.3.1/dist/simpleNotification.min.css">
|
||||
<script defer src="./index.js" type="module"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/uikit@3.10.0/dist/js/uikit.min.js"></script>
|
||||
|
|
@ -24,4 +25,4 @@
|
|||
<script src="https://cdn.jsdelivr.net/gh/Glagan/SimpleNotification@v1.3.1/dist/simpleNotification.min.js"></script>
|
||||
</head>
|
||||
<body class="App uk-light uk-background-secondary"></body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
|||
16
src/public/opensearch.xml
Normal file
16
src/public/opensearch.xml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OpenSearchDescription
|
||||
xmlns="http://a9.com/-/spec/opensearch/1.1/"
|
||||
xmlns:moz="http://www.mozilla.org/2006/browser/search/"
|
||||
>
|
||||
<ShortName>Play Search</ShortName>
|
||||
<LongName>Advanced Google Play Search</LongName>
|
||||
<Description>Filter and sort Google Play search results with Play Search.</Description>
|
||||
<InputEncoding>UTF-8</InputEncoding>
|
||||
<Url
|
||||
type="text/html"
|
||||
method="get"
|
||||
template="https://playsearch.kaki87.net/?q={searchTerms}"
|
||||
/>
|
||||
<moz:SearchForm>https://playsearch.kaki87.net/</moz:SearchForm>
|
||||
</OpenSearchDescription>
|
||||
Loading…
Add table
Add a link
Reference in a new issue