I'm trying to do this: Change the url https://www.brick-hill.com/shop/140880/
To this https://api.brick-hill.com/v1/games/retrieveAsset?id=140880&type=obj
我正在尝试更改网址,同时将数字100保留为其他网址。
Here my code: javascript:(function(){location.replace(window.location.href.replace("https://www.brick-hill.com/shop/","https://api.brick-hill.com/v1/games/retrieveAsset?id="))})();
链接变成这样:
https://api.brick-hill.com/v1/games/retrieveAsset?id=140880/
我想知道是否有某种方法可以解决这个问题?
https://api.brick-hill.com/v1/games/retrieveAsset?id=140880&type=obj
抱歉,格式化错误。
尝试使用正则表达式替换:
基本思想是对URL的域名和商店ID进行正则表达式匹配。然后,我们使用第一个和第二个捕获组构建输出URL。