13
13
// @description :it Una piccola estensione che aggiunge la traduzione vocale del video dal browser Yandex ad altri browser
14
14
// @description :ru Небольшое расширение, которое добавляет закадровый перевод видео из Яндекс Браузера в другие браузеры
15
15
// @description :zh 一个小扩展,它增加了视频从Yandex浏览器到其他浏览器的画外音翻译
16
- // @version 1.5.0-beta6
16
+ // @version 1.5.0-beta7
17
17
// @author sodapng, mynovelhost, Toil, SashaXser, MrSoczekXD
18
18
// @supportURL https://github.com/ilyhalight/voice-over-translation/issues
19
19
// @match *://*.youtube.com/*
@@ -3703,7 +3703,23 @@ class VideoHandler {
3703
3703
async init ( ) {
3704
3704
if ( this . initialized ) return ;
3705
3705
3706
- this . data = await GM_getValue ( "ext-data" , { } ) ;
3706
+ this . data = {
3707
+ autoTranslate : await GM_getValue ( "autoTranslate" , 0 ) ,
3708
+ dontTranslateYourLang : await GM_getValue ( "dontTranslateYourLang" , 1 ) ,
3709
+ autoSetVolumeYandexStyle : await GM_getValue ( "autoSetVolumeYandexStyle" , 1 ) ,
3710
+ showVideoSlider : await GM_getValue ( "showVideoSlider" , 1 ) ,
3711
+ syncVolume : await GM_getValue ( "syncVolume" , 0 ) ,
3712
+ subtitlesMaxLength : await GM_getValue ( "subtitlesMaxLength" , 300 ) ,
3713
+ highlightWords : await GM_getValue ( "highlightWords" , 0 ) ,
3714
+ responseLanguage : await GM_getValue ( "responseLanguage" , lang ) ,
3715
+ defaultVolume : await GM_getValue ( "defaultVolume" , 100 ) ,
3716
+ udemyData : await GM_getValue ( "udemyData" , {
3717
+ accessToken : "" ,
3718
+ expires : 0 ,
3719
+ } ) ,
3720
+ audioProxy : await GM_getValue ( "audioProxy" , 0 ) ,
3721
+ showPiPButton : await GM_getValue ( "showPiPButton" , 0 ) ,
3722
+ } ;
3707
3723
this . videoData = await this . getVideoData ( ) ;
3708
3724
3709
3725
debug /* default */ . Z . log ( "[db] data from db: " , this . data ) ;
@@ -3790,7 +3806,7 @@ class VideoHandler {
3790
3806
fromDialogTitle : localizationProvider . get ( "videoLanguage" ) ,
3791
3807
fromItems : [
3792
3808
{
3793
- label : " auto",
3809
+ label : localizationProvider . get ( "langs" ) [ " auto"] ,
3794
3810
value : "auto" ,
3795
3811
selected : "" ,
3796
3812
} ,
@@ -3830,7 +3846,7 @@ class VideoHandler {
3830
3846
const newLang = e . target . dataset . votValue ;
3831
3847
debug /* default */ . Z . log ( "[toOnSelectCB] select to language" , newLang ) ;
3832
3848
this . data . responseLanguage = this . translateToLang = newLang ;
3833
- await GM_setValue ( "ext-data " , this . data ) ;
3849
+ await GM_setValue ( "responseLanguage " , this . data . responseLanguage ) ;
3834
3850
debug /* default */ . Z . log (
3835
3851
"Response Language value changed. New value: " ,
3836
3852
this . data . responseLanguage ,
@@ -4181,7 +4197,7 @@ class VideoHandler {
4181
4197
"input" ,
4182
4198
async ( e ) => {
4183
4199
this . data . defaultVolume = Number ( e . target . value ) ;
4184
- await GM_setValue ( "ext-data " , this . data ) ;
4200
+ await GM_setValue ( "defaultVolume " , this . data . defaultVolume ) ;
4185
4201
this . votVideoTranslationVolumeSlider . label . querySelector (
4186
4202
"strong" ,
4187
4203
) . innerHTML = `${ this . data . defaultVolume } %` ;
@@ -4199,7 +4215,7 @@ class VideoHandler {
4199
4215
"change" ,
4200
4216
async ( e ) => {
4201
4217
this . data . autoTranslate = Number ( e . target . checked ) ;
4202
- await GM_setValue ( "ext-data " , this . data ) ;
4218
+ await GM_setValue ( "autoTranslate " , this . data . autoTranslate ) ;
4203
4219
debug /* default */ . Z . log (
4204
4220
"autoTranslate value changed. New value: " ,
4205
4221
this . data . autoTranslate ,
@@ -4211,7 +4227,7 @@ class VideoHandler {
4211
4227
"change" ,
4212
4228
async ( e ) => {
4213
4229
this . data . dontTranslateYourLang = Number ( e . target . checked ) ;
4214
- await GM_setValue ( "ext-data " , this . data ) ;
4230
+ await GM_setValue ( "dontTranslateYourLang " , this . data . dontTranslateYourLang ) ;
4215
4231
debug /* default */ . Z . log (
4216
4232
"dontTranslateYourLang value changed. New value: " ,
4217
4233
this . data . dontTranslateYourLang ,
@@ -4223,7 +4239,7 @@ class VideoHandler {
4223
4239
"change" ,
4224
4240
async ( e ) => {
4225
4241
this . data . autoSetVolumeYandexStyle = Number ( e . target . checked ) ;
4226
- await GM_setValue ( "ext-data " , this . data ) ;
4242
+ await GM_setValue ( "autoSetVolumeYandexStyle " , this . data . autoSetVolumeYandexStyle ) ;
4227
4243
debug /* default */ . Z . log (
4228
4244
"autoSetVolumeYandexStyle value changed. New value: " ,
4229
4245
this . data . autoSetVolumeYandexStyle ,
@@ -4235,7 +4251,7 @@ class VideoHandler {
4235
4251
"change" ,
4236
4252
async ( e ) => {
4237
4253
this . data . showVideoSlider = Number ( e . target . checked ) ;
4238
- await GM_setValue ( "ext-data " , this . data ) ;
4254
+ await GM_setValue ( "showVideoSlider " , this . data . showVideoSlider ) ;
4239
4255
debug /* default */ . Z . log (
4240
4256
"showVideoSlider value changed. New value: " ,
4241
4257
this . data . showVideoSlider ,
@@ -4251,14 +4267,14 @@ class VideoHandler {
4251
4267
accessToken : e . target . value ,
4252
4268
expires : new Date ( ) . getTime ( ) ,
4253
4269
} ;
4254
- await GM_setValue ( "ext-data " , this . data ) ;
4270
+ await GM_setValue ( "udemyData " , this . data . udemyData ) ;
4255
4271
debug /* default */ . Z . log ( "udemyData value changed. New value: " , this . data . udemyData ) ;
4256
4272
window . location . reload ( ) ;
4257
4273
} ) ;
4258
4274
4259
4275
this . votSyncVolumeCheckbox . input . addEventListener ( "change" , async ( e ) => {
4260
4276
this . data . syncVolume = Number ( e . target . checked ) ;
4261
- await GM_setValue ( "ext-data " , this . data ) ;
4277
+ await GM_setValue ( "syncVolume " , this . data . syncVolume ) ;
4262
4278
debug /* default */ . Z . log (
4263
4279
"syncVolume value changed. New value: " ,
4264
4280
this . data . syncVolume ,
@@ -4267,7 +4283,7 @@ class VideoHandler {
4267
4283
4268
4284
this . votAudioProxyCheckbox . input . addEventListener ( "change" , async ( e ) => {
4269
4285
this . data . audioProxy = Number ( e . target . checked ) ;
4270
- await GM_setValue ( "ext-data " , this . data ) ;
4286
+ await GM_setValue ( "audioProxy " , this . data . audioProxy ) ;
4271
4287
debug /* default */ . Z . log (
4272
4288
"audioProxy value changed. New value: " ,
4273
4289
this . data . audioProxy ,
@@ -4278,7 +4294,7 @@ class VideoHandler {
4278
4294
"input" ,
4279
4295
async ( e ) => {
4280
4296
this . data . subtitlesMaxLength = Number ( e . target . value ) ;
4281
- await GM_setValue ( "ext-data " , this . data ) ;
4297
+ await GM_setValue ( "subtitlesMaxLength " , this . data . subtitlesMaxLength ) ;
4282
4298
this . votSubtitlesMaxLengthSlider . label . querySelector (
4283
4299
"strong" ,
4284
4300
) . innerHTML = `${ this . data . subtitlesMaxLength } ` ;
@@ -4290,7 +4306,7 @@ class VideoHandler {
4290
4306
"change" ,
4291
4307
async ( e ) => {
4292
4308
this . data . highlightWords = Number ( e . target . checked ) ;
4293
- await GM_setValue ( "ext-data " , this . data ) ;
4309
+ await GM_setValue ( "highlightWords " , this . data . highlightWords ) ;
4294
4310
debug /* default */ . Z . log (
4295
4311
"highlightWords value changed. New value: " ,
4296
4312
this . data . highlightWords ,
@@ -4303,7 +4319,7 @@ class VideoHandler {
4303
4319
"change" ,
4304
4320
async ( e ) => {
4305
4321
this . data . showPiPButton = Number ( e . target . checked ) ;
4306
- await GM_setValue ( "ext-data " , this . data ) ;
4322
+ await GM_setValue ( "showPiPButton " , this . data . showPiPButton ) ;
4307
4323
debug /* default */ . Z . log (
4308
4324
"showPiPButton value changed. New value: " ,
4309
4325
this . data . showPiPButton ,
@@ -4317,7 +4333,18 @@ class VideoHandler {
4317
4333
4318
4334
this . votResetSettingsButton . addEventListener ( "click" , ( ) => {
4319
4335
localizationProvider . reset ( ) ;
4320
- GM_deleteValue ( "ext-data" ) ;
4336
+ GM_deleteValue ( "autoTranslate" )
4337
+ GM_deleteValue ( "dontTranslateYourLang" )
4338
+ GM_deleteValue ( "autoSetVolumeYandexStyle" )
4339
+ GM_deleteValue ( "showVideoSlider" )
4340
+ GM_deleteValue ( "syncVolume" )
4341
+ GM_deleteValue ( "subtitlesMaxLength" )
4342
+ GM_deleteValue ( "highlightWords" )
4343
+ GM_deleteValue ( "responseLanguage" )
4344
+ GM_deleteValue ( "defaultVolume" )
4345
+ GM_deleteValue ( "udemyData" )
4346
+ GM_deleteValue ( "audioProxy" )
4347
+ GM_deleteValue ( "showPiPButton" )
4321
4348
window . location . reload ( ) ;
4322
4349
} ) ;
4323
4350
}
0 commit comments