gpt4 book ai didi

javascript - 获取子域名并使用greasemonkey将其加载到url

转载 作者:行者123 更新时间:2023-12-02 23:02:46 25 4
gpt4 key购买 nike

我有 URL http://somesubdomain.domain.com (子域可能会有所不同,域始终相同)。需要使用greasemonkey获取子域名并使用类似domain.com/some/path/here/somesubdomain的内容重新加载页面(或者使用URLdomain.com/some/path/here/somesubdomain等打开一个新窗口)。

最佳答案

var full = window.location.host
//window.location.host is subdomain.domain.com
var parts = full.split('.')
var sub = parts[0]
var domain = parts[1]
var type = parts[2]
//sub is 'subdomain', 'domain', type is 'com'
var newUrl = 'http://' + domain + '.' + type + '/your/other/path/' + subDomain
window.open(newUrl);

关于javascript - 获取子域名并使用greasemonkey将其加载到url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1282726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com