Updated translator script.
This commit is contained in:
		
							parent
							
								
									b11f3e9368
								
							
						
					
					
						commit
						c6dc304627
					
				@ -17,17 +17,31 @@ function checkFinished () {
 | 
				
			|||||||
function onResourceLoad (url) {
 | 
					function onResourceLoad (url) {
 | 
				
			||||||
    if (url.indexOf ('/translate_a/single') > -1) {
 | 
					    if (url.indexOf ('/translate_a/single') > -1) {
 | 
				
			||||||
        isTranslationFinished = true;
 | 
					        isTranslationFinished = true;
 | 
				
			||||||
 | 
					        if (isPageLoaded) {
 | 
				
			||||||
            checkFinished ();
 | 
					            checkFinished ();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
st_wtp.resourceLoaded.connect (onResourceLoad);
 | 
					st_wtp.resourceLoaded.connect (onResourceLoad);
 | 
				
			||||||
function onPageLoad () {
 | 
					function onPageLoad () {
 | 
				
			||||||
 | 
					    if (window.location.href.indexOf('about:blank') === 0) {
 | 
				
			||||||
 | 
					        translate ();
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    isPageLoaded = true;
 | 
					    isPageLoaded = true;
 | 
				
			||||||
 | 
					    if (isTranslationFinished) {
 | 
				
			||||||
        checkFinished ();
 | 
					        checkFinished ();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
window.onload = onPageLoad();
 | 
					window.onload = onPageLoad();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function translate (){
 | 
					function translate (){
 | 
				
			||||||
 | 
					    if (window.location.href.indexOf('https://translate.google') === 0) {
 | 
				
			||||||
 | 
					        window.location = 'about:blank';
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var url = 'https://translate.google.com/#auto/' +
 | 
					    var url = 'https://translate.google.com/#auto/' +
 | 
				
			||||||
            st_wtp.resultLanguage + '/' + st_wtp.sourceText;
 | 
					            st_wtp.resultLanguage + '/' + st_wtp.sourceText;
 | 
				
			||||||
    window.location = encodeURI (url);
 | 
					    window.location = encodeURI (url);
 | 
				
			||||||
 | 
				
			|||||||
@ -18,7 +18,7 @@
 | 
				
			|||||||
        "path": "translators/bing.js"
 | 
					        "path": "translators/bing.js"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "Google translator": {
 | 
					    "Google translator": {
 | 
				
			||||||
        "version": 1,
 | 
					        "version": 2,
 | 
				
			||||||
        "url": "https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/google.js",
 | 
					        "url": "https://raw.githubusercontent.com/OneMoreGres/ScreenTranslator/master/translators/google.js",
 | 
				
			||||||
        "path": "translators/google.js"
 | 
					        "path": "translators/google.js"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user