Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

111
Visualizações
Convert url in address bar to localhost in Chrome

i need to create a marker in my web browser, to be faster in my job. I need to convert some url like: https://www.myTest.com/section/the-new-section/ to localhost/pf/section/the-new-section/ Maybe then i will need to add something after the address like ?_website=mypageSite, or something. but is secondary. The thing is the first part.

I try to use this code like model to make main, but i can not achieve any result:

javascript:u=u=window.location.href.replace(/^https?:\/\/[^\/]+/,%20%27%27).replace(/(\?|#).*$/,%20'');d=window.location.href.match(/^(?:https?:\/\/)?(?:[^@\n]+@)?(?:www\.)?([^:\/\n?]+)/)[1];a='https://'+d+'/pf/api/v3/content/fetch/content-api-v4?query={%22website_url%22:%22'+u+'%22}';x=new%20XMLHttpRequest();x.open('GET',a,false);x.send(null);o=JSON.parse(x.responseText);if(o%20&&%20o._id){window.location.href%20=%20'https://diarioas.arcpublishing.com/composer/edit/'+o._id+'/';}else{'Story%20URL%20not%20found';}

i need similar to do that i comment before. Some help for me. Thanks

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Just use the URL API.

const str = 'https://www.mytest.com/section/the-new-section/';

const url = new URL(str);

console.log(`localhost/pf${url.pathname}`);

about 4 years ago · Juan Pablo Isaza Relatório

0

There are two cases for this question,
First is when you are at that pagehttps://www.mytest.com/section/the-new-section/ then you then you can just use window.location.pathname to get the parameters and to get stuff like ?search=stackoverflow you can use window.location.search

console.log( "http://localhost"+window.location.pathname+window.location.search)

Second Interpretation is that you need a custom function to do this for a set of url's you provide... This is also similar to the above approach.

var url = "https://www.mytest.com/section/the-new-section/?search=stackoverflow"
var urlt = new URL(url)
console.log("http://localhost" + urlt.pathname + urlt.search)

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda