Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

107
Views
Convierta la URL en la barra de direcciones a localhost en Chrome

necesito crear un marcador en mi navegador web, para ser más rápido en mi trabajo. Necesito convertir alguna URL como: https://www.myTest.com/section/the-new-section/ to localhost/pf/section/the-new-section/ Tal vez entonces tendré que agregar algo después de la dirección como ?_website=mypageSite, o algo así. pero es secundario. La cosa es la primera parte.

Intento usar este código como modelo para hacer main, pero no puedo lograr ningún resultado:

 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';}

Necesito similar para hacer eso que comento antes. Un poco de ayuda para mí. Gracias

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Simplemente use la API de URL .

 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 Report

0

Hay dos casos para esta pregunta,
Primero es cuando estás en esa página https://www.mytest.com/section/the-new-section/ luego puedes usar window.location.pathname para obtener los parámetros y obtener cosas como ?search=stackoverflow puede usar window.location.search

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

La segunda interpretación es que necesita una función personalizada para hacer esto para un conjunto de direcciones URL que proporcione... Esto también es similar al enfoque anterior.

 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!