mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-21 12:48:28 +00:00
implement opensearch
This commit is contained in:
parent
e6e9f4f099
commit
4887aaf559
3
.gitignore
vendored
3
.gitignore
vendored
@ -24,3 +24,6 @@ docker-compose.yml
|
||||
|
||||
# cookie file
|
||||
cookies.json
|
||||
|
||||
# opensearch xml build
|
||||
src/front/opensearch*
|
||||
|
@ -610,6 +610,11 @@ window.onload = () => {
|
||||
detectColorScheme();
|
||||
popup("migration", 1);
|
||||
}
|
||||
if (pageQuery.has("opensearchquery")) {
|
||||
eid("url-input-area").value = pageQuery.get("opensearchquery");
|
||||
button();
|
||||
eid("download-button").click();
|
||||
}
|
||||
window.history.replaceState(null, '', window.location.pathname);
|
||||
|
||||
notificationCheck();
|
||||
|
@ -157,6 +157,9 @@
|
||||
"SettingsTwitterGifDescription": "converting looping videos to .gif reduces quality and majorly increases file size. if you want best efficiency, keep this setting off.",
|
||||
"UpdateTwitterGif": "twitter gifs and pinterest",
|
||||
"ErrorTweetProtected": "this tweet is from a private account, so i can't see it. try another one!",
|
||||
"ErrorTweetNSFW": "this tweet contains sensitive content, so i can't see it. try another one!"
|
||||
"ErrorTweetNSFW": "this tweet contains sensitive content, so i can't see it. try another one!",
|
||||
"ErrorOpenSearch": "<!-- the opensearch xml file failed to build for language {s} :( -->",
|
||||
"OpenSearchTitle": "Cobalt",
|
||||
"OpenSearchDescription": "Cobalt is your go-to place for downloads from social and media platforms. Zero ads, trackers, or other creepy bullshit. Simply paste a share link and you're ready to rock!"
|
||||
}
|
||||
}
|
||||
|
@ -159,6 +159,9 @@
|
||||
"SettingsTwitterGifDescription": "конвертирование зацикленного видео в .gif снижает качество и значительно увеличивает размер файла. если важна максимальная эффективность, то не используй эту функцию.",
|
||||
"UpdateTwitterGif": "гифки с твиттера и одноклассники",
|
||||
"ErrorTweetProtected": "этот твит из закрытого аккаунта, поэтому я не могу его увидеть. попробуй другой!",
|
||||
"ErrorTweetNSFW": "этот твит содержит деликатный контент, поэтому я не могу его увидеть. попробуй другой!"
|
||||
"ErrorTweetNSFW": "этот твит содержит деликатный контент, поэтому я не могу его увидеть. попробуй другой!",
|
||||
"ErrorOpenSearch": "<!-- TODO TRANSLATE ME!! the opensearch xml file failed to build for language {s} :( -->",
|
||||
"OpenSearchTitle": "TODO TRANSLATE ME!! Cobalt",
|
||||
"OpenSearchDescription": "TODO TRANSLATE ME!! Cobalt is your go-to place for downloads from social and media platforms. Zero ads, trackers, or other creepy bullshit. Simply paste a share link and you're ready to rock!"
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import { loadLoc, languageList } from "../localization/manager.js";
|
||||
import { cleanHTML } from "./sub/utils.js";
|
||||
|
||||
import page from "./pageRender/page.js";
|
||||
import buildOpenSearch from "./pageRender/buildOpenSearch.js";
|
||||
|
||||
export async function buildFront(commitHash, branch) {
|
||||
try {
|
||||
@ -31,6 +32,9 @@ export async function buildFront(commitHash, branch) {
|
||||
}
|
||||
fs.writeFileSync(`./build/pc/${i}.html`, cleanHTML(page(params)));
|
||||
|
||||
// build opensearch xml
|
||||
fs.writeFileSync(`./src/front/opensearch-${i}.xml`, cleanHTML(buildOpenSearch(i)));
|
||||
|
||||
params["useragent"] = "iphone os";
|
||||
fs.writeFileSync(`./build/ios/${i}.html`, cleanHTML(page(params)));
|
||||
|
||||
|
21
src/modules/pageRender/buildOpenSearch.js
Normal file
21
src/modules/pageRender/buildOpenSearch.js
Normal file
@ -0,0 +1,21 @@
|
||||
import loc from "../../localization/manager.js";
|
||||
|
||||
export default function (lang) {
|
||||
const t = (str, replace) => { return loc(lang, str, replace) };
|
||||
|
||||
const strippedURL = process.env.webURL.replace(/^https?:\/\//, '').replace(/\/$/, '');
|
||||
|
||||
try {
|
||||
return `
|
||||
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
|
||||
<ShortName>${t('OpenSearchTitle')}</ShortName>
|
||||
<Description>${t("OpenSearchDescription")}</Description>
|
||||
<Url type="text/html" method="get" template="${process.env.webURL}?opensearchquery={searchTerms}" />
|
||||
<Image height="48" width="48" type="image/x-icon">${process.env.webURL}icons/favicon.ico</Image>
|
||||
<Tags>cobalt download</Tags>
|
||||
</OpenSearchDescription>
|
||||
`
|
||||
} catch (err) {
|
||||
return `${t('ErrorOpenSearchBuildFail', lang)}`;
|
||||
}
|
||||
}
|
@ -38,6 +38,8 @@ export default function(obj) {
|
||||
|
||||
audioFormats[0]["text"] = t('SettingsAudioFormatBest');
|
||||
|
||||
const strippedURL = process.env.webURL.replace(/^https?:\/\//, '').replace(/\/$/, '');
|
||||
|
||||
try {
|
||||
return `
|
||||
<!DOCTYPE html>
|
||||
@ -57,6 +59,8 @@ export default function(obj) {
|
||||
<meta name="theme-color" content="#000000">
|
||||
<meta name="twitter:card" content="summary">
|
||||
|
||||
<link rel="search" href="/opensearch-${obj.lang}.xml" type="application/opensearchdescription+xml" title="${t('OpenSearchTitle')}">
|
||||
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<meta name="apple-mobile-web-app-title" content="${t("AppTitleCobalt")}">
|
||||
|
Loading…
Reference in New Issue
Block a user