【发布时间】:2015-08-26 20:08:07
【问题描述】:
这基本上是Combining Bookmarklets to create a toggle between HTTP and HTTPS?的变体
我想将以下两个小书签合二为一:
javascript:q=(document.location.href);location=location.href.replace('dp','gp/aw/d')
javascript:q=(document.location.href);location=location.href.replace('gp/aw/d','dp')
即基本上在服务器上的两个目录之间切换。
这不起作用(或仅适用于其中一种情况,即它不切换 'dp' 情况)。
javascript:q=(document.location.href);location=location.href.replace('dp','gp/aw/d').replace('gp/aw/d','dp');
任何(正则表达式)改进,例如因此,欢迎切换只会捕获 url 中第一次出现的“dp”。
【问题讨论】:
标签: javascript regex url bookmarklet