【问题标题】:A bookmarklet to use a portion of the current URL in a new URL在新 URL 中使用当前 URL 的一部分的小书签
【发布时间】:2011-12-16 13:44:34
【问题描述】:

我想做一个小书签来改变网页

http://user.tumblr.com/post/123456789
http://user.tumblr.com/liked/by/user

只需点击一下。我通常可以一起使用 frankensteining 代码,而且我一直在查看使用“window.location”的 Tumblr 手动转发按钮以及 Bookmarklet to edit current URLReplace end characters of current URL with bookmarklet

我看不到任何可以将子域提取到变量中然后将其放置在新 URL 中的东西。我确实偶然发现了这段代码:

^http://([^.]+)\.domain\.com

但我不知道这意味着什么或如何使用它。

【问题讨论】:

    标签: javascript url subdomain bookmarklet tumblr


    【解决方案1】:

    不确定这是否是您要查找的内容,但我使用的是因为我的网站有多个实例,并且无论端口或协议如何,都有哪些书签可以让我保持在同一个实例中。

    新标签

    javascript:(function(){window.open(location.protocol+'//'+location.hostname+':'+location.port+'/liked/by/user')})();
    

    当前标签

    javascript:(function(){window.location.assign(location.protocol+'//'+location.hostname+':'+location.port+'/liked/by/user')})();
    

    编辑:忘记放代码块

    【讨论】:

    • 效果很好,有没有办法检测子域(location.subdomain 不起作用)并用它替换'user'?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-23
    • 1970-01-01
    • 2019-09-06
    • 1970-01-01
    • 1970-01-01
    • 2013-10-27
    • 1970-01-01
    相关资源
    最近更新 更多