Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

87
Vistas
How to modify URL in loading page?

UPDATE: I realize now that in the scenario described below I will need to be careful of infinite loops since the page being redirected to is the same (minus the added param) as the initial page. Does anyone have any experience with that in Webextensions and can offer any advice on how best to avoid these loops?


I've written a few Webextensions for Firefox before but it's been a few years (a little out of practise). But a new problem has arisen for which I can see no solution except to write my own Webextension.

How would I modify the URL of a page and add a query parameter? I am specifically trying to modify the URL of Google Docs pages and add the query param ?mode=html

So for example, a Google Docs URL might look like: https://docs.google.com/document/d/7Ujfjsd69To7lInXFOdn49nAxLLhfn43fj43JHDTp87/edit

I am looking to create an extension that will modify that URL so it becomes: https://docs.google.com/document/d/7Ujfjsd69To7lInXFOdn49nAxLLhfn43fj43JHDTp87/edit?mode=html

(Obviously I only want this param appended when the URL being loaded matches https://docs.google.com/document/d/*)

Can anyone give me a pointer on how to start that? What extensionAPI function(s) would I need to use to do that? At what point in the lifespan of the request should it happen etc?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Note: requires "webRequest" & "webRequestBlocking" permission plus host permission

// add a listener for https://docs.google.com/document/*
browser.webRequest.onBeforeRequest.addListener(process, {
    urls: ['https://docs.google.com/document/*'],
    types: ['main_frame']
  },
  ['blocking']
);

function process(details) {
  // check it doesn't have mode=html
  if (!details.url.includes('mode=html')) {
    // add &mode=html if URL already has search string, otherwsie ?mode=html
    return {redirectUrl: details.url + (details.url.includes('?') ? '&' : '?') + 'mode=html'};
  }
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda