| Summary: | Google translation bar bookmarklet does not work | ||
|---|---|---|---|
| Product: | [Applications] Falkon | Reporter: | Theo <alpha0x89> |
| Component: | general | Assignee: | David Rosca <nowrep> |
| Status: | REOPENED --- | ||
| Severity: | normal | CC: | jurajoravec |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | openSUSE | ||
| OS: | Linux | ||
| Latest Commit: | https://commits.kde.org/falkon/956b99c1cb2a3db0f3f429c9eb8f2a38e06862c5 | Version Fixed/Implemented In: | 3.1.0 |
| Sentry Crash Report: | |||
|
Description
Theo
2018-07-17 17:22:07 UTC
I can't get this working on Firefox. But Bookmarklets are working at all in Falkon.
Here is an example you can try on the current page:
================== EXAMPLE BOOKMARKLET ======================
javascript:mt=document.getElementsByTagName('meta')[0].getAttribute('content');if(mt){alert('Content of the current page is: '+mt)};
=============================================================
Git commit 956b99c1cb2a3db0f3f429c9eb8f2a38e06862c5 by David Rosca. Committed on 24/12/2018 at 14:03. Pushed by drosca into branch 'master'. BrowserWindow: Use LoadRequest in loadAddress FIXED-IN: 3.1.0 M +1 -1 src/lib/app/browserwindow.cpp https://commits.kde.org/falkon/956b99c1cb2a3db0f3f429c9eb8f2a38e06862c5 The translation bookmarklet still doesn't work for me in Falkon 3.1.0. The_assassin's example works fine. Hello,
There is probably some mistake in that code (it is old).
1. As mentioned, you need to use https otherwise it will work only on http sites
2. we can get rid or 'scri'+'pt' and replace it with 'script' (it is easier to read)
3. And here comes the obstacle
- Remove: v.style.display='none';
It will display some selectbox to manually trigger translating
- Use the select box to trigger the translating, the translate bar will appear
- After this was done, when you use this bookmarklet again on the same tab it will display the selectbox and also the translate toolbar and loads a lots of scripts
4. So I presume it is some kind of error with javascript or some execution thing...
5. The workaround is not so bad...
====
javascript:%7Bd=document;b=d.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';p=d.createElement('script');p.setAttribute('type','text/javascript');p.text='function%20googleTranslateElementInit()%7Bnew%20google.translate.TranslateElement(%7BpageLanguage:%22%22%7D,%22google_translate_element%22);%7D';b.appendChild(p);%7D
====
(In reply to Juraj from comment #4) > - Remove: v.style.display='none'; > It will display some selectbox to manually trigger translating > - Use the select box to trigger the translating, the translate bar will > appear I confirm that this workaround works as described, and here is an interesting observation: once this workaround has been applied and a page has been translated, the original bookmarklet works now on any page on the same site, but only as long as I don't click "Show original" in the translation bar. |