diff --git a/mods/translations/resources/en.json b/mods/translations/resources/en.json index 2ac9efd1..4c883a90 100644 --- a/mods/translations/resources/en.json +++ b/mods/translations/resources/en.json @@ -165,6 +165,10 @@ "ttSettings": { "title": "TizenTube Settings", "madeByText": "Made by Reis Can (reisxd) with ❤️", + "versionInfo": { + "standalone": "Standalone {{standaloneVersion}} · Module {{moduleVersion}}", + "module": "Module {{moduleVersion}}" + }, "summary": "Open TizenTube Settings" }, "supportTT": { @@ -203,4 +207,4 @@ "skipToHighlight": "Skip to highlight" } } -} \ No newline at end of file +} diff --git a/mods/ui/settings.js b/mods/ui/settings.js index cd3da273..b382115d 100644 --- a/mods/ui/settings.js +++ b/mods/ui/settings.js @@ -3,10 +3,16 @@ import { showModal, buttonItem, overlayPanelItemListRenderer, scrollPaneRenderer import qrcode from 'qrcode-npm'; import { t } from 'i18next'; import { getComprehensiveLanguageList } from '../features/moreSubtitles.js'; +import { getStandaloneVersion, moduleVersion } from '../version.js'; const qrcodes = {}; export default function modernUI(update, parameters) { + const standaloneVersion = getStandaloneVersion(); + const versionText = standaloneVersion + ? t('settings.ttSettings.versionInfo.standalone', { standaloneVersion, moduleVersion }) + : t('settings.ttSettings.versionInfo.module', { moduleVersion }); + const settings = [ { name: t('settings.supportTT.title'), @@ -887,7 +893,7 @@ export default function modernUI(update, parameters) { showModal( { title: t('settings.ttSettings.title'), - subtitle: t('settings.ttSettings.madeByText') + subtitle: `${versionText}\n${t('settings.ttSettings.madeByText')}` }, overlayPanelItemListRenderer(buttons, parameters && parameters.length > 0 ? parameters[0] : 0), 'tt-settings', diff --git a/mods/version.js b/mods/version.js new file mode 100644 index 00000000..3aa3965f --- /dev/null +++ b/mods/version.js @@ -0,0 +1,22 @@ +import packageInfo from '../package.json'; + +export const moduleVersion = packageInfo.version; + +export function getStandaloneVersion() { + if (window.__tizenTubeStandaloneVersion) { + return window.__tizenTubeStandaloneVersion; + } + + try { + if (typeof tizen === 'undefined' || !tizen.application) return null; + + const appInfo = tizen.application.getCurrentApplication().appInfo; + if (appInfo?.id.endsWith(".TizenTubeStandalone")) { + return appInfo.version; + } + } catch (error) { + console.warn('Failed to read the TizenTube standalone version:', error); + } + + return null; +} diff --git a/standalone/service/index.js b/standalone/service/index.js index 017361f6..81b20e01 100644 --- a/standalone/service/index.js +++ b/standalone/service/index.js @@ -10,6 +10,7 @@ const http = require('http'); const https = require('https'); const URL = require('url'); const injector = require('./injector.js'); +const standaloneVersion = tizen.application.getAppInfo().version; app.use((req, res, next) => { res.setHeader('Access-Control-Allow-Origin', '*'); @@ -139,6 +140,7 @@ app.all('*', (req, res) => { return response.text().then((text) => { if (req.url.indexOf('/tv') === 0 && req.url.indexOf('/tv_config') === -1) { // Insert the userscript for TizenTube + text += ``; text += ``; } @@ -197,4 +199,4 @@ app.listen(PORT, "127.0.0.1"); // Start the DIAL server global.isTizenTube = true; -require('../../dist/service.js'); \ No newline at end of file +require('../../dist/service.js'); diff --git a/standalone/service/injector.js b/standalone/service/injector.js index f1d2c87c..3a77e436 100644 --- a/standalone/service/injector.js +++ b/standalone/service/injector.js @@ -4,6 +4,7 @@ const adbhost = require('adbhost'); const CDP = require('chrome-remote-interface'); const fetch = require('node-fetch'); +const standaloneVersion = tizen.application.getAppInfo().version; var isConnecting = false; const isTizen3 = tizen.systeminfo.getCapability('http://tizen.org/feature/platform.version').startsWith('3.0'); @@ -17,7 +18,10 @@ function connectToDebugger(host, port, args) { client.on('Runtime.executionContextCreated', m => { fetch('https://cdn.jsdelivr.net/npm/@foxreis/tizentube/dist/userScript.js').then(res => res.text()).then(modFile => { - client.Runtime.evaluate({ expression: modFile, contextId: m.context.id }); + client.Runtime.evaluate({ + expression: `window.__tizenTubeStandaloneVersion = ${JSON.stringify(standaloneVersion)};\n${modFile}`, + contextId: m.context.id + }); }).catch(e => { client.Runtime.evaluate({ expression: 'alert("Failed to request to JSDelivr CDN.")', contextId: m.context.id }); }); @@ -67,4 +71,4 @@ function startDebugger(args) { module.exports = { startDebugger, canConnectToDaemon -}; \ No newline at end of file +};