I am facing a problem in JS. window.location.href shows the full location of a URL. window.location.hostname shows the hostname. window.location.pathname shows the path. but what code do I need to use for the extension to show.
Example
URL is https://www.w3schools.com/js/tryit.asp?filename=tryjs_loc_href
I get
window.location.href: https://www.w3schools.com/js/tryit.asp?filename=tryjs_loc_href
window.location.hostname: www.w3schools.com
window.location.pathname: /js/tryit.asp
what code? = filename=tryjs_loc_href
if you don't understand Please see the picture

My Code is
document.getElementById("demo").innerHTML = "The full URL of this page is:<br>" + window.location.href;
<span id="demo"></span>
Use the URL searchParams or just location.search (here also available in the url
const url = new URL("https://www.w3schools.com/js/tryit.asp?filename=tryjs_loc_href")
const search = url.search; // or location.search
console.log(search.slice(1)); // remove the ?
console.log(url.searchParams.get("filename")); // or get just the filename
PS: I recommend MDN over w3schools any day