Google Translate shows blank screen in Chrome - google-chrome

Google Translator has stopped working in Chrome 85.0.4183 (also in Canary, Opera, Edge).
For example, after pressing "Translate" button at https://colnect.com/en/collectors/collector/teleawe
it shows "about:blank#blocked". The Translate button itself has "about:invalid#zClosurez" link.
The xhr request to https://translate.googleapis.com/translate_a/t?anno=... is shown as cancelled in devtool console.
Also here is notice about cross-site cookies affected to https://translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=en request.
The same link works well in Firefox.
Also https://codepen.io/paul/pen/ZZzEpQ sample works, it's without callback but also shows the translation service still working.
Could you please help me how to fix this issue?

I have the same problem.
I fix it with the following code :
$(document).ready(function(){
setTimeout( function() {
$(".goog-te-gadget-link").click(function(){
$(this).attr('href', 'javascript:;');
});
}, 2000);
});
If you have a better solution, I'll take it :)
Regards

I had same few days ago and fixed by evt.preventDefault(). Just add this to google-translate link. After this translate will work by clicking at link
somePlaceWithThsProblem.$el.on('click', '.goog-te-gadget-link', (event) => {
event.preventDefault();
});

Related

chrome goes back 2 times instead of one time when using history.pushState/location.hash

open a new tab in Chrome (opens http://google.com for example)
open a testpage.htm containing history.pushState({},"test","#lightbox");
which changes the url to testpage.htm#lightbox
if you hit the back button of your chrome the url is changed to http://google.com, which is two states back, not one
firefox and msie10 work both good, so it's a chrome issue
how can i fix this? is there a workaround?
thank you in advance
(feel free to give my question a better title and feel free to correct my english)
notes:
on step 2 you can also use window.location.hash = "#lightbox" but does the same issue
on step 3 you can simulate the back button from within your code, using history.back() and in this very case the url is switched to the correct one testpage.htm, so this is related only to the back button of Chrome's gui
I also tried
window.addEventListener("popstate", function(ev){ ev.preventDefault(); });
window.addEventListener("hashchange", function(ev){ ev.preventDefault(); });
without success :(
Update 2: does the same using History.js

Open popup and change the icon in a Google Chrome Extension

So, I'm trying to do a simple extension for Google Chrome.
What I'm trying to do is: When I click at the icon of my extension it will apppear (the popup.html) and change the icon to default.png.
What I've done so far:
$(document).ready(function() {
chrome.browserAction.onClicked.addListener(function(tab)
{
chrome.browserAction.setIcon({path:"default.png"});
});
});
The problem is... it only shows up the popup.html... the icon doesnt change. :(
May somebody help me??
Thanks in advance
This sample extension on developer.chrome.com does exactly what you want.
A browser action which changes its icon when clicked.

How to detect when the chrome devtools is closed and trigger a function in background.js

I'm currently writing a chrome extension that has it's own panel in the Devtools. Although I'm facing an issue. I'm trying to trigger some action in the background page when the Devtools panel of a specific tab is closed.
I tried adding this to devtools.js :
window.onbeforeunload = function(event) {
port.postMessage({action: 'disableTab', tabId: tabID});
return "Are you sure you want to navigate away?";
};
Although the confirmation is never displayed and the message is never posted.
I think that it's because my devtools.html / devtools.js file isn't the one that is handling the main Devtools panel. it' only appended to it, something like that.
I'm still searching for an answer, anyone knows how I could achieve that ?
Edit:
I just noticed that this app is doing exactly what I want! https://developers.google.com/speed/pagespeed/insights_extensions
Run an analysis, then try closing the devtools, you'll be prompted.

How can I debug why clicking a link is not working in IE8 / IE9?

I have a simple html link that doesn't do anything in IE8. No errors, it just sits there. It works fine in Chrome and FF. The link is just a clickable image:
<p><a id="google-purchase-link" href="/purchase/google" data-ajax="false"><img src="https://checkout.google.com/buttons/checkout.gif?merchant_id=763453611943044&w=180&h=46&style=trans&variant=text&loc=en_GB" alt="Proceed to Google Checkout"/></a></p>
To try it yourself :
Visit http://www.oddprints.com/checkout
Click "Upload something"
Click "Sample photo"
Click "Order prints"
Click "Buy with Google"
Don't worry, you won't be committing to buy anything!
In IE, the link doesn't seem to work, it just sits there. The link simply points to /purchase/google which builds up the cart server-side and then returns a temporary redirect to the populated Google checkout page. If you visit http://www.oddprints.com/purchase/google it performs the redirect fine.
Any ideas how I can debug this?
UPDATE:
The link is being handled with javascript. I have to specifically add the href attribute to window.location to make it work in IE8, however the problem still occurs in IE9.
Changed:
$("#google-purchase-link").click(function(e){
_gaq.push(function() {
var pageTracker = _gaq._getAsyncTracker();
setUrchinInputCode(pageTracker);
console.log(getUrchinFieldValue());
window.location = "/purchase/google?analyticsData=" + getUrchinFieldValue();
});
e.preventDefault();
});
to
$("#google-purchase-link").click(function(e){
_gaq.push(function() {
var pageTracker = _gaq._getAsyncTracker();
setUrchinInputCode(pageTracker);
console.log(getUrchinFieldValue());
window.location.href = "/purchase/google?analyticsData=" + getUrchinFieldValue();
});
e.preventDefault();
});
UPDATE: the problem was using console.log(). Doh!
Problem was using console.log().
Doh!

Message Passing in Chrome

Have a small doubt in how message passing works in chrome using content scrips. I modified the default example (http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/messaging/timer/) for message passing given in the chromium documentation to the one that looks below :
popup.html
function testRequest() {
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.sendRequest(tab.id, {counter: "getHTML"}, function handler(response) {
alert("Inside Client = "+response.counter2);
});
});
}
and my content script looks like this :
page.js
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
alert(request.counter);
alert("Inside server .. Req Counter = "+request.counter);
sendResponse({counter2: "5"});
});
When I execute the testRequest from popup.html, the content script is getting called as expected. I do get both the alerts i have
declared with their respective values. But my popup.html response code doesnt seem to be called .. The alert I have inside the popup.html - alert("Inside Client = "+response.counter2); is not being executed.
On the other hand, If i have a debug point inside the client, its working ! Kinda strange.. Can somebody tell me how and why this is happening ?
Thank you in advance..
your code is correct. I am mistaken what I said before.
Believe me when I say it, I was puzzled why it didn't work. It turned out to be that I am running the browser action on the chrome://extensions/ page. In Chrome Extensions, the API will not let you execute or send any requests to that page. Do it on a normal page like Google.com and you will see your popup.
You cannot show an alert dialog within popup page.
That is why you don't see: alert("Inside Client = "+response.counter2); }
If you want to see it working, you can add a console logger and view it within the Web Inspector. Replace the alert with: console.log(response.counter2);
As far as I can tell, alerts from a popup will only appear if the popup is open.
You see the alert when you're debugging the popup because the debugger keeps the popup open.
I'm pretty sure there are also no problems with creating alerts from the background page.