diff --git a/dist/debugHelper.js b/dist/debugHelper.js index e0df8619..d8aa6d71 100644 --- a/dist/debugHelper.js +++ b/dist/debugHelper.js @@ -1,8 +1,11 @@ // ==UserScript== -// @name 油猴调试助手 +// @name h5player DebugHelper +// @name:en h5player DebugHelper +// @name:zh 油猴调试助手 // @namespace https://github.com/xxxily/TampermonkeyDebugHelper // @version 0.0.1 -// @description 用于油猴脚本的本地开发调试使用 +// @description Used for local development and debugging of TamperMonkey script +// @description:zh 用于油猴脚本的本地开发调试使用 // @author xxxily // @match http://*/* // @match https://*/* @@ -113,10 +116,10 @@ const _debugTools_ = { const t = this return new Promise((resolve, reject) => { t.get(scriptUrl + '?t=' + Date.now()).catch(err => { - console.log('脚本内容加载出错~') + console.log('脚本内容加载出错~ / Error loading script <' + scriptUrl + '>') resolve('') }).then(res => { - console.log('脚本内容更新成功~') + console.log('脚本内容更新成功~ / Script <' + scriptUrl + '> was updated successfully') if (saveToNamespace) { window.GM_setValue(saveToNamespace, res.responseText) } diff --git a/src/h5player/comment.js b/src/h5player/comment.js index 5092f7e5..dadc1060 100644 --- a/src/h5player/comment.js +++ b/src/h5player/comment.js @@ -1,5 +1,5 @@ // ==UserScript== -// @name HTML5视频播放器增强脚本 +// @name HTML5 video player enhanced script // @name:en HTML5 video player enhanced script // @name:zh HTML5视频播放器增强脚本 // @name:zh-TW HTML5視頻播放器增強腳本 @@ -10,7 +10,7 @@ // @namespace https://github.com/xxxily/h5player // @homepage https://github.com/xxxily/h5player // @version 3.3.9 -// @description HTML5视频播放增强脚本,支持所有H5视频播放网站,全程快捷键控制,支持:倍速播放/加速播放、视频画面截图、画中画、网页全屏、调节亮度、饱和度、对比度、自定义配置功能增强等功能。 +// @description HTML5 video playback enhanced script, supports all H5 video playback websites, full-length shortcut key control, supports: double-speed playback / accelerated playback, video screenshots, picture-in-picture, full-page webpage, brightness, saturation, contrast, custom configuration enhancement And other functions. // @description:en HTML5 video playback enhanced script, supports all H5 video playback websites, full-length shortcut key control, supports: double-speed playback / accelerated playback, video screenshots, picture-in-picture, full-page webpage, brightness, saturation, contrast, custom configuration enhancement And other functions. // @description:zh HTML5视频播放增强脚本,支持所有H5视频播放网站,全程快捷键控制,支持:倍速播放/加速播放、视频画面截图、画中画、网页全屏、调节亮度、饱和度、对比度、自定义配置功能增强等功能。 // @description:zh-TW HTML5視頻播放增強腳本,支持所有H5視頻播放網站,全程快捷鍵控制,支持:倍速播放/加速播放、視頻畫面截圖、畫中畫、網頁全屏、調節亮度、飽和度、對比度、自定義配置功能增強等功能。 diff --git a/src/h5player/h5PlayerTccInit.js b/src/h5player/h5PlayerTccInit.js index 82c7c2a4..dc8c0d5c 100644 --- a/src/h5player/h5PlayerTccInit.js +++ b/src/h5player/h5PlayerTccInit.js @@ -365,6 +365,8 @@ function h5PlayerTccInit (h5Player) { return task(h5Player, taskConf, data) } catch (e) { console.error('TCC自定义函数任务执行失败:', h5Player, taskConf, data) + console.error('TCC fail:', e) + h5Player.tipsI('tipsMsg.configError', taskName) return false } } else { diff --git a/src/h5player/index.js b/src/h5player/index.js index a8193939..03b81f05 100644 --- a/src/h5player/index.js +++ b/src/h5player/index.js @@ -666,6 +666,13 @@ const originalMethods = { return tispContainer }, + tipsI: function (...strs) { + const t = h5Player + let out = strs + out = out.map(s => i18n.t(s) || s) + out = out.join('') + return t.tips(out) + }, tips: function (str) { const t = h5Player const player = t.player() @@ -1288,6 +1295,7 @@ const originalMethods = { if (!curTime || Number.isNaN(curTime)) return if (t.isAllowRestorePlayProgress()) { + debug.log('playbackrestored:', curTime, 'from', player.currentTime) player.currentTime = curTime || player.currentTime if (curTime > 3) { t.tips(i18n.t('tipsMsg.playbackrestored')) diff --git a/src/h5player/locale/core-lang/en-US.js b/src/h5player/locale/core-lang/en-US.js index bf47f650..4ecce99f 100644 --- a/src/h5player/locale/core-lang/en-US.js +++ b/src/h5player/locale/core-lang/en-US.js @@ -6,6 +6,7 @@ export default { donate: 'donate', disableInitAutoPlay: 'Prohibit autoplay of videos on this site', tipsMsg: { + configError: 'Exception for this config in function: ', playspeed: 'Speed: ', forward: 'Forward: ', backward: 'Backward: ', diff --git a/src/libs/I18n/index.js b/src/libs/I18n/index.js index 0b27b0cb..a04799b0 100644 --- a/src/libs/I18n/index.js +++ b/src/libs/I18n/index.js @@ -18,6 +18,7 @@ class I18n { /* 指定当前要是使用的语言环境,默认无需指定,会自动读取 */ t._languages = config.languages || t._languages t._defaultLanguage = config.defaultLanguage || t._defaultLanguage + t.changeLanguage(t._locale) } use () {} @@ -44,12 +45,25 @@ class I18n { } changeLanguage (locale) { - if (this._languages[locale]) { - this._languages = locale - return locale + var fallback = this._languages[locale] + // alias is a string language name instead of a map + if (typeof fallback !== 'string') fallback = locale + // if found, assume a map + if (this._languages[fallback]) { + this._locale = fallback + console.log('Lang set:', this._locale) + return this._locale + } + // if lang-REGION, try lang only + fallback = fallback.split('-') + fallback = fallback.length > 0 && fallback[0] + if (fallback && this._languages[fallback]) { + this._locale = fallback } else { - return false + this._locale = this._defaultLanguage } + console.log('Lang set:', this._locale, 'Not available:', locale) + return this._locale } /** @@ -59,7 +73,10 @@ class I18n { * @returns {*} */ getValByPath (obj, path) { - path = path || '' + /* No need to check, if not a string */ + if (typeof path !== 'string') return '' + if (!path) return '' + const pathArr = path.split('.') let result = obj