替换发布商学术登录的网址中的域名

时间:2013-12-03 20:05:44

标签: javascript login bookmarklet gateway

在我的大学IP域之外工作时,我必须使用登录服务器访问发布者网站。 大多数形式为http://pubs.domain.org/XXX.html的网址都会转换为http://pubs.domain.org.gateway.university.edu/XXX.html

问题是:大多数发布商网站都有一个无用的搜索工具,因此我使用google并登陆常规网站,并且在大学之外使用Web of Knowledge通常无法连接到发布者。我发现只要我在过去一小时内进行了身份验证,手动替换URL就会起作用。

我正在寻找一种使用bookmarklet自动执行此操作的方法。我发现这个问题似乎是我正在寻找的,但我之前从未使用过javascript而且无法适应它。 Bookmarklet to edit current URL

谢谢!

3 个答案:

答案 0 :(得分:1)

javascript:(function() {
  window.location.href =
    location.protocol 
    + '//'+location.hostname
    + '.gateway.university.edu'
    + location.pathname
    + location.search;
})();

答案 1 :(得分:1)

我最近遇到过这种情况。由于您要为主机名附加后缀,但是保持URL不变,您可以直接编辑window.location.hostname以触发重新加载:

javascript:window.location.hostname += '.gateway.university.edu';

或关闭:

javascript:(function() {
  window.location.hostname += '.gateway.university.edu';
})();

答案 2 :(得分:0)

window.location.href = window.location.href.replace("://pubs.domain.org","://pubs.domain.org.gateway.university.edu");