google translate page scripts dont work?
-
translate.google.com
why all the script dont work on this site? i use it with tampermonkey or violentmonkey
all other brower the script is working with this site, only vivaldi it doesnt work.
for example this script:
https://greasyfork.org/en/scripts/374339-google-translate-utils
it doesnt work at all with vivaldi (opera, firefox, chrome, edge all work) -
@hien4990 , maybe Vivaldis own translator cause this problem.
-
@catweazle thanks, i found 2 setting
- Automatically offer to Translate Pages
- Show Selected Text Translate Button
it already in disabled state, do i need to disable something else?
-
@hien4990 , I don't know, I don't use Google Translate. Try it.
-
@hien4990 I tried this script, and I get the following error in both Edge and Vivaldi (in the DevTools console):
Uncaught TypeError: Cannot read properties of null (reading 'appendChild')
. Didn't have time to investigate the code, but it seems broken to me.Do you have any other examples?
-
thanks for reply here is another example
https://greasyfork.org/scripts/16204/
i recently tested it again with edge firefox chrome it work falwlessly, on vivaldi nothing happen, still cant figure out why, i tried many diffence settings with no luck
i have about 20 scripts on tampermonkey and violentmonkey and non of them is working on vivaldi in translate.google.com, like all the script is disable when entering the site. -
@hien4990 I forgot to mention. Both scripts use the
innerHTML
function which causes theThis document requires 'TrustedHTML' assignment.
error message to appear. For the first example, I changedinnerHTML
toinnerText
, so that I was left with only theUncaught TypeError
.In this example, I'm not even sure what the script is supposed to do, it simply fails in both Edge and Vivaldi. It's strange that you're getting different results in Edge, as it's built on Chromium, just like Vivaldi. Perhaps you had it installed in other browsers earlier, and some new version broke the functionality?
-
@pafflick said in google translate page scripts dont work?:
Perhaps
thanks for your inform after update chrome, edge and vivaldi both fail, only firefox, opera is good, so chromium browsers now block scripts from google transate page like google extension page, one more reason to abandon chrome lol.
-
@hien4990 said in google translate page scripts dont work?:
so chromium browsers now block scripts from google transate page like google extension page
It's not necessarily the case, it looks like the page itself has been updated, and therefore the code of the scripts needs to be updated accordingly.
I tried tweaking the first code (since it's far simpler than the second one) and I managed to make it work in Vivaldi (well, at least it shows the button). The query selector refers to the old structure of the document, which doesn't seem to exist anymore.
To be exact, I replaced this:
container = document.querySelector('body > div.container > div.frame > div.page.tlid-homepage.homepage.translate-text > div.input-button-container'),
with this:container = document.getElementsByClassName('hgbeOc')[0],
, changedinnerHTML
toinnerText
, updated classes and got something like this, which works (although I'm still not sure what it's supposed to do):(function() { 'use strict'; var textarea = document.getElementById('source'), container = document.getElementsByClassName('hgbeOc')[0], customButton = document.createElement('div'), replaceOn = false; function replaceWord(){ if (typeof replaceWord.innerFunc === 'undefined'){ replaceWord.innerFunc = function (){ textarea.value = textarea.value.replace(/-[\r\n]/g,'').replace(/[\r\n]/g,' '); } } setTimeout(replaceWord.innerFunc, 200); } customButton.addEventListener('click',function(event){ if(!replaceOn){ replaceOn = true; customButton.style.backgroundColor='#E4ECFA'; textarea.addEventListener('paste', replaceWord); replaceWord(); }else{ replaceOn = false; customButton.style.backgroundColor='#FAFAFA'; textarea.removeEventListener('paste', replaceWord); } }); customButton.className = 'tlid-input-button input-button header-button tlid-input-button-docs'; customButton.appendChild(document.createElement('div')); customButton.childNodes[0].innerText = '自动替换换行'; customButton.childNodes[0].className = 'VfPpkd-LgbsSe VfPpkd-LgbsSe-OWXEXe-INsAgc VfPpkd-LgbsSe-OWXEXe-Bz112c-M1Soyc Rj2Mlf OLiIxf PDpWxe irkilc'; container.appendChild(customButton); })();
I guess you would have to call the
textarea
with something else thantextarea = document.getElementById('source')
to make it actually work. -
Ppafflick moved this topic from Vivaldi for Windows on
-
Ppafflick moved this topic from Websites on