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

141
Views
replacing the location fuction with custom function

I have seen a proxy website with code similar to this, but there code is obfuscated.

The proxy website changes window.location to window._location

Only 5/7 attempts work below... How do i achieve the other 2?

    var _location = {
        set function(url) {
            window.location = url + "?search=query";
        },
        get href() {
            return window.location.href;
        },
        get protocol() {
            return window.location.protocol;
        },
        get hostname() {
            return window.location.hostname;
        },
        get pathname() {
            return window.location.pathname;
        },
        set href(url) {
            window.location.href = url + "?search=query";
        }
    }

    _location.assign = function(url) {
        window.location.assign(url + "?search=query");
    };

    _location.replace = function(url) {
        window.location.replace(url + "?search=query");
    };

    console.log(window._location.href); // Working
    console.log(_location.href); // Working
    window._location = 'https://stackoverflow.com'; // NOT Working
    window._location.href = 'https://stackoverflow.com'; // Working
    window._location.assign('https://stackoverflow.com'); // Working
    window._location.replace('https://stackoverflow.com'); // Working
    _location = 'https://stackoverflow.com';// NOT Working
about 4 years ago · Juan Pablo Isaza
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!