Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion mods/translations/resources/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -203,4 +207,4 @@
"skipToHighlight": "Skip to highlight"
}
}
}
}
8 changes: 7 additions & 1 deletion mods/ui/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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',
Expand Down
22 changes: 22 additions & 0 deletions mods/version.js
Original file line number Diff line number Diff line change
@@ -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;
}
4 changes: 3 additions & 1 deletion standalone/service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', '*');
Expand Down Expand Up @@ -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 += `<script>window.__tizenTubeStandaloneVersion = ${JSON.stringify(standaloneVersion)};</script>`;
text += `<script src="https://cdn.jsdelivr.net/npm/@foxreis/tizentube/dist/userScript.js?ver=${Date.now()}"></script>`;
}

Expand Down Expand Up @@ -197,4 +199,4 @@ app.listen(PORT, "127.0.0.1");

// Start the DIAL server
global.isTizenTube = true;
require('../../dist/service.js');
require('../../dist/service.js');
8 changes: 6 additions & 2 deletions standalone/service/injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 });
});
Expand Down Expand Up @@ -67,4 +71,4 @@ function startDebugger(args) {
module.exports = {
startDebugger,
canConnectToDaemon
};
};