Cerca nel supporto

Attenzione alle mail truffa. Mozilla non chiederà mai di chiamare o mandare messaggi a un numero di telefono o di inviare dati personali. Segnalare qualsiasi attività sospetta utilizzando l'opzione “Segnala abuso”.

Learn More

Questa discussione è archiviata. Inserire una nuova richiesta se occorre aiuto.

Modify URL in address bar with Javascript

  • 4 risposte
  • 3 hanno questo problema
  • 2 visualizzazioni
  • Ultima risposta di AAronoff

more options

I was using a bookmarklet in Firefox that modified the URL in the address bar to switch the page view in Gmail from text to HTML after "Show original" was selected for a particular message:

javascript:window.location=window.location.href.replace("view=om&th","view=lg&msg");

This bookmarklet no longer works.

Is there any way to allow Javascript to access the URL in the address bar?

TIA and regards, Andy

I was using a bookmarklet in Firefox that modified the URL in the address bar to switch the page view in Gmail from text to HTML after "Show original" was selected for a particular message: javascript:window.location=window.location.href.replace("view=om&th","view=lg&msg"); This bookmarklet no longer works. Is there any way to allow Javascript to access the URL in the address bar? TIA and regards, Andy

Tutte le risposte (4)

more options

If I look at Gmail then I see the &v parameter, so maybe try that. Maybe also try not to depend on the order of parameters and split them over more replace calls. I don't know about the 'lg' value (view=lg) as I'm not seeing it in the page source.

  • javascript:void(location.href=location.href.replace("&v=om","&v=c").replace("",""));
more options

FOA, thanks for your reply.

I don't think my problem has been understood.

The Javascript in my first message is correctly constructed. It worked for well over a year in Firefox and it works correctly in IE 11. The problem is not the Javascript. It's Firefox, which appears to have been hardened to refuse access to the URL in the address bar by Javascript in a bookmarklet. (I also tried it in Safe Mode, with no success.)

Are you able to modify the URL in the address bar via Javascript from a Firefox 55.0.3 (Windows 32-bit) bookmarklet? If not, Is there any way to allow this access via about:config?

regards, Andy

more options

OK, that looks like a CSP issue where the website only allows to run scripts from their own website (self).

Unfortunately Firefox applies CSP rules to bookmarklets and thus you can't run these.

You can run the JavaScript code in the Web Console as a workaround.

I don't know whether NoScript can bypass CSP restrictions for bookmarklets.

more options

> that looks like a CSP issue

I'm no longer sure what the issue is.

I uninstalled Firefox and installed previous versions. That had no effect.

I created a brand new profile. That had no effect, either.

A bookmarklet worked for a long time and then suddenly stopped working. (It continues to work in IE 11.)

I checked the bookmarklet in Firefox 55.0.3 on another Windows 7 PC. It didn't work there, either.

I don't understand why this bookmarklet stopped working in Firefox.

Thanks for trying to help.