Added and updated translators.
This commit is contained in:
		
							parent
							
								
									3a564e85a8
								
							
						
					
					
						commit
						a7ffec8827
					
				
							
								
								
									
										33
									
								
								translators/bing.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								translators/bing.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,33 @@
 | 
			
		||||
var isPageLoaded = false;
 | 
			
		||||
var isTranslationFinished = false; // async translation request
 | 
			
		||||
var isScheduled = false;
 | 
			
		||||
 | 
			
		||||
function checkFinished () {
 | 
			
		||||
    if (!isPageLoaded || !isTranslationFinished || isScheduled) return;
 | 
			
		||||
    isScheduled = true;
 | 
			
		||||
    setTimeout(function () {
 | 
			
		||||
        var spans = [].slice.call (document.querySelectorAll ('#OutputText span'));
 | 
			
		||||
        var text = spans.reduce (function (res, i) {
 | 
			
		||||
            return res + i.innerText;
 | 
			
		||||
        }, '');
 | 
			
		||||
        st_wtp.translated (text);
 | 
			
		||||
    }, 500); // wait for gui fill
 | 
			
		||||
}
 | 
			
		||||
function onResourceLoad (url) {
 | 
			
		||||
    if (url.indexOf ('/api.microsofttranslator.com/') > -1) {
 | 
			
		||||
        isTranslationFinished = true;
 | 
			
		||||
        checkFinished ();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
st_wtp.resourceLoaded.connect (onResourceLoad);
 | 
			
		||||
function onPageLoad () {
 | 
			
		||||
    isPageLoaded = true;
 | 
			
		||||
    checkFinished ();
 | 
			
		||||
}
 | 
			
		||||
window.onload = onPageLoad();
 | 
			
		||||
 | 
			
		||||
function translate (){
 | 
			
		||||
    var url = 'https://bing.com/translator/?text=' + st_wtp.sourceText + '#auto/' +
 | 
			
		||||
            st_wtp.resultLanguage;
 | 
			
		||||
    window.location = encodeURI (url);
 | 
			
		||||
}
 | 
			
		||||
@ -1,14 +1,17 @@
 | 
			
		||||
var isPageLoaded = false;
 | 
			
		||||
var isTranslationFinished = false; // async translation request
 | 
			
		||||
var isScheduled = false;
 | 
			
		||||
 | 
			
		||||
function checkFinished () {
 | 
			
		||||
    if (!isPageLoaded || !isTranslationFinished) return;
 | 
			
		||||
    if (!isPageLoaded || !isTranslationFinished || isScheduled) return;
 | 
			
		||||
    isScheduled = true;
 | 
			
		||||
    setTimeout(function () {
 | 
			
		||||
        var spans = [].slice.call (document.querySelectorAll ('#result_box > span'));
 | 
			
		||||
        var text = spans.reduce (function (res, i) {
 | 
			
		||||
            return res + ' ' + i.innerText;
 | 
			
		||||
        }, '');
 | 
			
		||||
        st_wtp.translated (text);
 | 
			
		||||
        isTranslationFinished = isScheduled = false;
 | 
			
		||||
    }, 500); // wait for gui fill
 | 
			
		||||
}
 | 
			
		||||
function onResourceLoad (url) {
 | 
			
		||||
@ -27,5 +30,5 @@ window.onload = onPageLoad();
 | 
			
		||||
function translate (){
 | 
			
		||||
    var url = 'https://translate.google.com/#auto/' +
 | 
			
		||||
            st_wtp.resultLanguage + '/' + st_wtp.sourceText;
 | 
			
		||||
    window.location = url;
 | 
			
		||||
    window.location = encodeURI (url);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										31
									
								
								translators/yandex.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								translators/yandex.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,31 @@
 | 
			
		||||
var isPageLoaded = false;
 | 
			
		||||
var isTranslationFinished = true; // async translation request
 | 
			
		||||
var isScheduled = false;
 | 
			
		||||
 | 
			
		||||
function checkFinished () {
 | 
			
		||||
    if (!isPageLoaded || !isTranslationFinished || isScheduled) return;
 | 
			
		||||
    isScheduled = true;
 | 
			
		||||
    setTimeout(function () {
 | 
			
		||||
        var spans = [].slice.call (document.querySelectorAll ('#translation > span'));
 | 
			
		||||
        var text = spans.reduce (function (res, i) {
 | 
			
		||||
            return res + i.innerText;
 | 
			
		||||
        }, '');
 | 
			
		||||
        st_wtp.translated (text);
 | 
			
		||||
    }, 500); // wait for gui fill
 | 
			
		||||
}
 | 
			
		||||
function onResourceLoad (url) {
 | 
			
		||||
}
 | 
			
		||||
st_wtp.resourceLoaded.connect (onResourceLoad);
 | 
			
		||||
function onPageLoad () {
 | 
			
		||||
    isPageLoaded = true;
 | 
			
		||||
    checkFinished ();
 | 
			
		||||
}
 | 
			
		||||
window.onload = onPageLoad();
 | 
			
		||||
 | 
			
		||||
function translate (){
 | 
			
		||||
    var url = 'https://translate.yandex.ru/?text=' + st_wtp.sourceText + '&lang=auto-' +
 | 
			
		||||
            st_wtp.resultLanguage;
 | 
			
		||||
    url = url.replace(new RegExp(' ','g') , '%20')
 | 
			
		||||
    console.log(encodeURI(url));
 | 
			
		||||
    window.location = (url);
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user