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

116
Views
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 answers
Answer question

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 Report

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 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!