Last active
August 12, 2024 19:28
-
-
Save illusionfield/db576c73a103f37e0044 to your computer and use it in GitHub Desktop.
Translate Bookmarklets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Web browsers use URIs for the href attribute of the <a> tag and for bookmarks. The URI scheme, such as http:, file:, or ftp:, specifies the protocol and the format for the rest of the string. | |
* Browsers also implement a prefix javascript: that to a parser is just like any other URI. | |
* Internally, the browser sees that the specified protocol is javascript, treats the rest of the string as a JavaScript application which is then executed, and uses the resulting string as the new page. | |
* | |
* The executing script has access to the current page, which it may inspect and change. | |
* If the script returns an undefined type (rather than, for example, a string), the browser will not load a new page, with the result that the script simply runs against the current page content. | |
* This permits changes such as in-place font size and color changes without a page reload. | |
*/ | |
/* An anonymous function that does not return a value, define a function etc., can be used to force the script to return an undefined type: */ | |
javascript:(function(){ | |
//Statements returning a non-undefined type, e.g. assignments | |
})(); | |
/* However, if a script includes a function definition/redefinition, such as function Use_this_globally(){...}, the environment will not be populated with it. For this reason an {arbitrary script} should be suffixed with ;void(...);. */ | |
javascript:{arbitrary script};void(0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:{var d,b,o,v,p;b=(d=document).body;o=d.createElement('script');o.setAttribute('src','https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit');o.setAttribute('type','text/javascript');b.appendChild(o);v=b.insertBefore(d.createElement('div'),b.firstChild);v.id='google_translate_element';v.style.display='none';p=d.createElement('script');p.text='function googleTranslateElementInit(){new google.translate.TranslateElement({pageLanguage:""},"google_translate_element");}';p.setAttribute('type','text/javascript');b.appendChild(p);};void(0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
translator = document.createElement "script" | |
translator.setAttribute "src", "https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit" | |
translator.setAttribute "type", "text/javascript" | |
document.body.appendChild translator | |
element = document.body.insertBefore document.createElement("div"), document.body.firstChild | |
element.id = "google_translate_element" | |
element.style.display = "none" | |
elementInit = document.createElement "script" | |
elementInit.text = 'function googleTranslateElementInit(){new google.translate.TranslateElement({pageLanguage:""},"google_translate_element");}' | |
elementInit.setAttribute "type", "text/javascript" | |
document.body.appendChild elementInit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: { | |
s=document.createElement("script"); | |
s.setAttribute("type", "text/javascript"); | |
s.setAttribute("src", "http://labs.microsofttranslator.com/bookmarklet/default.aspx?f=js&to=hu"); | |
document.body.appendChild(s); | |
};void(0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:{s=document.createElement("script");s.setAttribute("type","text/javascript");s.setAttribute("src","http://labs.microsofttranslator.com/bookmarklet/default.aspx?f=js&to=hu");document.body.appendChild(s);};void(0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function()%20%7Bvar%20protocol%20=%20window.location.protocol%20===%20'file:'%20?'http:'%20:%20'';var%20url%20=%20protocol+'//www.sprymedia.co.uk/VisualEvent/VisualEvent_Loader.js';if(%20typeof%20VisualEvent!='undefined'%20)%20%7Bif%20(%20VisualEvent.instance%20!==%20null%20)%20%7BVisualEvent.close();%7Delse%20%7Bnew%20VisualEvent();%7D%7Delse%20%7Bvar%20n=document.createElement('script');n.setAttribute('language','JavaScript');n.setAttribute('src',url+'?rand='+new%20Date().getTime());document.body.appendChild(n);%7D%7D)(); |
Can someone make a bookmarklet that uses the DeepL translator? For me DeepL gives better translations than Google Translate
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bookmarklet with icon: