To get the path, you can use:
var pathname = window.location.pathname; // Returns path only (/path/example.html)
var url = window.location.href; // Returns full URL (https://example.com/path/example.html)
var origin = window.location.origin; // Returns base URL (https://example.com)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…