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

145
Views
how would I keep my js code from working on certain subdomains

if I am trying to execute a warning to the console every time the url switched how would I exclude a website such as twitter.com/(username)/topics if the username is unique to the user every time

let lastUrl = location.href;
new MutationObserver(() => {
const url = location.href;
if (url !== lastUrl) {
lastUrl = url;

onUrlChange();



}

}).observe(document, {subtree: true, childList: true});

`window.__ttrExcludeUrls = ["https://twitter.com/explore",` "https://twitter.com/home","https://twitter.com/notifications", "https://twitter.com/messages", "https://twitter.com/i/bookmarks","https://twitter.com/i/moment_maker","https://.twitter.com/i/*"];



 function onUrlChange()
    {
      console.warn("URL changed", location.href);
    
      if(window.__ttrExcludeUrls.includes(location.href) == false)
      {
        console.log("THIS IS A TEST MESSAGE")
      }
      else
      {
        console.warn("WRONG URL")
      }
      if(location.href == "https://twitter.com/home")
      {
        console.warn("WRONG URL")
      }
      
    }
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!